From: "AaronLasseigne (Aaron Lasseigne)" Date: 2012-03-21T11:26:05+09:00 Subject: [ruby-core:43512] [ruby-trunk - Feature #6180] to_b for converting objects to a boolean value Issue #6180 has been updated by AaronLasseigne (Aaron Lasseigne). @drbrain - Very true but it is nice to be consistent with return values. It makes testing a little easier and fits a little better with the principle of least surprise. @hasari - to_s could easily be string or symbol. It doesn't seem unreasonable to use to_b for boolean. However, I'm not opposed to to_bool or to_boolean if needed. It's a little ugly but it could even be something like to_tf (to true/false). @trans - It seems to me like that could become difficult to manage across languages and cultural expectations. Also, that could be covered with "true?" and "false?" methods similar to how Rails has "blank?" and "present?" for strings. In fact it strikes me as something that's more Rails like than Ruby like but I don't know exactly why. "yes".true? #=> true "no".true? #=> false 1.true? #=> true 0.false? #=> true ---------------------------------------- Feature #6180: to_b for converting objects to a boolean value https://bugs.ruby-lang.org/issues/6180#change-24993 Author: AaronLasseigne (Aaron Lasseigne) Status: Open Priority: Normal Assignee: Category: Target version: When a boolean return value is required it has become common practice is to use "!!" to convert the object. It would be more consistent to provide a "to_b" method on Object. -- http://bugs.ruby-lang.org/