mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Adding links to literals and Kernel (#5192)
* Adding links to literals and Kernel
This commit is contained in:
parent
324d57df0b
commit
28fb6d6b9e
Notes:
git
2021-12-03 22:13:00 +09:00
Merged-By: BurdetteLamar <BurdetteLamar@Yahoo.com>
10 changed files with 101 additions and 57 deletions
14
rational.c
14
rational.c
|
@ -2715,13 +2715,19 @@ nurat_s_convert(int argc, VALUE *argv, VALUE klass)
|
|||
* a/b (b>0), where a is the numerator and b is the denominator.
|
||||
* Integer a equals rational a/1 mathematically.
|
||||
*
|
||||
* In Ruby, you can create rational objects with the Kernel#Rational,
|
||||
* to_r, or rationalize methods or by suffixing +r+ to a literal.
|
||||
* The return values will be irreducible fractions.
|
||||
* You can create a \Rational object explicitly with:
|
||||
*
|
||||
* - A {rational literal}[doc/syntax/literals_rdoc.html#label-Rational+Literals].
|
||||
*
|
||||
* You can convert certain objects to Rationals with:
|
||||
*
|
||||
* - \Method {Rational}[Kernel.html#method-i-Rational].
|
||||
*
|
||||
* Examples
|
||||
*
|
||||
* Rational(1) #=> (1/1)
|
||||
* Rational(2, 3) #=> (2/3)
|
||||
* Rational(4, -6) #=> (-2/3)
|
||||
* Rational(4, -6) #=> (-2/3) # Reduced.
|
||||
* 3.to_r #=> (3/1)
|
||||
* 2/3r #=> (2/3)
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue