Feature #12626
closedAdd ceiling alias for ceil on Numeric objects
Description
Proposing adding a ceiling
alias to the ceil
instance method for Numeric, Float, Integer.
Although ceil
is familiar as it's an extremely common method name in other languages, ceiling
is more readable. Several other methods exist in the standard library with aliased long and short forms. A few examples:
Numeric:
[:imaginary, :imag]
[:rectangular, :rect]
[:to_i, :to_int]
[:conjugate, :conj]
String:
[:to_str, :to_s]
Usage:
> 2.71.ceil
=> 3
> 2.71.ceiling
=> 3
> Fixnum.instance_methods.grep /ceil/
=> [:ceil, :ceiling]
Files
Updated by jwillems (Jason Willems) almost 8 years ago
- File add_ceiling_alias.patch add_ceiling_alias.patch added
Updated by shevegen (Robert A. Heiler) over 7 years ago
I do not have any particular pro or con opinion here; personally I would continue to use .ceil but if other people use .ceiling
by default, it is up to them, not me. There is more than one way to do something.
I should, however had, point out that you equated String to_str with to_s and they are not the same.
http://blog.bigbinary.com/2012/06/26/to_str-in-ruby.html
Updated by matz (Yukihiro Matsumoto) over 7 years ago
- Status changed from Open to Rejected
Having both ceil
(backed by UNIX tradition) and ceiling
(better for English natives? dunno) only introduces confusion. Is there any other buying point for ceiling
?
Matz.