Project

General

Profile

Actions

Feature #10365

closed

`Rational#to_a` and `Array#to_r`

Added by sawa (Tsuyoshi Sawada) over 9 years ago. Updated over 9 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:65604]

Description

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]).

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0