Feature Request #20
Add Object#to_bool
| Status: | New | Start: | 02/22/2010 | |
| Priority: | Normal | Due date: | 03/31/2011 | |
| Assigned to: | Daniel Berger | % Done: | 0% |
|
| Category: | New Core Feature | Spent time: | - | |
| Target version: | 1.0 | Estimated time: | 4.00 hours | |
Description
An idiom that I see in the wild is this:
The goal there is to return false if the object is false or nil, true otherwise. In short, it's an
!!some_object
The goal there is to return false if the object is false or nil, true otherwise. In short, it's an
RTEST(), for those familiar with C extensions. The problem is that it's ugly and not entirely clear.
The Object#to_bool method is simply a nicer way of expressing the above idiom.