Code Pointers #07 — setting variables based on if-else statements
I came across some really lovely syntax that I wanted to record here.
value = if true
value #=> true_value
I’d seen this before but hadn’t taken the time to fully understand it.
It is equivalent to this:
value = :true_value
value = :false_value
But you can see how the first version is more DRY (do not repeat yourself) and more readable.