Project

General

Profile

Actions

Feature #8430

closed

Rational number literal

Added by mrkn (Kenta Murata) over 11 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
[ruby-core:55096]

Description

I would like to propose a new literal syntax for rational numbers.
The implementation is available in my github repository:
https://github.com/mrkn/ruby/commit/8ca0c9a53593e55d67f509fc403df616e2276e3a

This patch implements a notation that consists of an integer, "//", and another integer, in a row.
The first integer is the numerator, and the second is the denominator.
Whitespaces are permitted between them.

For example:
1 // 2 == Rational(1, 2)
1 // 1 == Rational(1, 1)
0 // 1 == Rational(0, 1)

"0 // 0" occurs syntax error.

I think this new syntax isn't conflict with an empty regexp
because this implementation doesn't treat // as a binary operator.


Files

ratio_lit.patch (2.11 KB) ratio_lit.patch A patch for the rational number literal takuto_h (Takuto Hayashi), 08/01/2013 04:53 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0