Project

General

Profile

Actions

Feature #7978

closed

boolean to_i

Added by alexeymuranov (Alexey Muranov) over 11 years ago. Updated over 11 years ago.

Status:
Rejected
Target version:
[ruby-core:52997]

Description

=begin
The current behavior is the following:

nil.to_i
=> 0
false.to_i
NoMethodError: undefined method `to_i' for false:FalseClass

true.to_i
NoMethodError: undefined method `to_i' for true:TrueClass

This does not look very consistent to me. I think it could be useful to define (({false.to_i})) as 0 and (({true.to_i})) as 1. I think those are fairly common numeric values for False and True. These values as strings "0" and "1" are also commonly used in HTML forms to represent boolean values.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0