Ruby/rails boolean

1 points by lastps ↗ HN
So I've come around to the ruby standard that everything is true except for nil and false, e.g., the integer 0 is true, etc. At first I didn't like it but now I think it makes a lot of sense.

A few things to think about --

Do people rely on database fields always being nil or do you initialize new objects to something else?

I find myself using the isblank? method (added to rails but is not present in ruby) to test for boolean a lot in my code. Do others make extensive use of this?

Is it a good working assumption to design around the idea that ruby/rails most always returns nil as the result of a method call resulting in nothing? (Obviously taking note of what actually occurs but starting from that general idea)

What other philosphies, tricks ideas do folks employ regarding booleans in ruby/rails?

My holy grail is a simple/clear/short best practices for boolean in ruby/rails. My current cheat sheet is more of a manifesto than a ten commandments.

0 comments

[ 4.1 ms ] story [ 12.6 ms ] thread

No comments yet.