David Heinemeier Hansson (DHH)
๐ค SpeakerAppearances Over Time
Podcast Appearances
Why is this question mark in here?
Because it just reads so nicely.
If user admin question mark.
That's a very human phrase, but it gets better.
You can turn this around.
You can have your statement you want to execute before the conditional.
You can do user.upgrade.
Let's say you're calling an upgrade method on a user.
Space if, space user.admin question mark.
We do the thing if the thing is true.
Instead of saying if the thing is true, do the thing.
But it gets even better.
This is why I love this example with the conditional, because you can keep diving into it.
So let's flip it around.
User dot downgrade if exclamation point not user dot admin.
Right.
That'd be a typical way of writing it.
Ruby goes, that exclamation point is light noise.
Why do we have if and then an exclamation point?
That's ugly.