[#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:65442] [ruby-trunk - Feature #10332] [Open] Rational literal for mixed fractions

From: sawadatsuyoshi@...
Date: 2014-10-06 14:55:49 UTC
List: ruby-core #65442
Issue #10332 has been reported by Tsuyoshi Sawada.

----------------------------------------
Feature #10332: Rational literal for mixed fractions
https://bugs.ruby-lang.org/issues/10332

* Author: Tsuyoshi Sawada
* Status: Open
* Priority: Normal
* Assignee: 
* Category: 
* Target version: 
----------------------------------------
Current behavior of rational literal and `String#to_r` does not recognize mixed fractions. Mixed fraction is not rare, and is frequently used in places such as US length measurement.

![drill bits](http://www.strongtie.com/graphics/anchorsystems/catalog/tables/217b-2012.gif)

I propose that rational literal and `String#to_r` should be extended to handle mixed fractions. Perhaps something like:

~~~ruby
8 1/2r #=> (17/2)
"8 1/2".to_r #=> (17/2)
~~~

or


~~~ruby
(8 1/2)r #=> (17/2)
~~~




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

In This Thread

Prev Next