3 ms·
Expanding "boolean-ness" and treating more things as expressions lets ruby give you more readable code. e.g. if user = db.query(id) user.update(...)
by JamesSwift 4y ago
Expanding "boolean-ness" and treating more things as expressions lets ruby give you more readable code. e.g.
if user = db.query(id)
user.update(...)
end
and
user = db.query(id) || raise "UserNotFound"
- deleted 4y ago[deleted]
- toomanybeersies 4y agoFYI your second example isn't actually valid ruby. You need to either wrap the arg for raise in parens: user = db.query(id) || raise("UserNotFound") Or use the `or` keyword: user = db.query(id) or raise "UserNotFound"
- JamesSwift 4y agoAh, thank you. I knew about the issue, but I actually changed it from an initial `or` because I had them mixed up. Instead of changing the boolean rules, they should definitely address the different precedence rules for boolean operators : )