[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...

Issue #10333 has been updated by Koichi Sasada.

9 messages 2014/10/07

[ruby-core:65605] [ruby-trunk - Feature #10365] `Rational#to_a` and `Array#to_r`

From: sawadatsuyoshi@...
Date: 2014-10-11 00:38:34 UTC
List: ruby-core #65605
Issue #10365 has been updated by Tsuyoshi Sawada.


Sorry, I meant

    2/51r.to_a # => [2, 51]

----------------------------------------
Feature #10365: `Rational#to_a` and `Array#to_r`
https://bugs.ruby-lang.org/issues/10365#change-49345

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
I guess people would want to extract the numerator and the denominator of an array. `to_a` would perhaps be a good name:

    (2/51).to_a # => [2, 51]

It also might be useful if `Array#to_r` were provided as an alternative way to create a rational from an array:

    [4, 6].to_r #=> (2/3)

This would be equivalent to `Rational(*[4, 6])`.



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next