David Heinemeier Hansson (DHH)
๐ค SpeakerAppearances Over Time
Podcast Appearances
That's the bedrock of all programming languages.
They have the if conditional.
If you take most programming languages, they all have if.
That's basically the same in almost every language.
Space, start parentheses.
We all do that.
And then you have, perhaps let's say you're calling a object called user.
dot isAdmin, close parentheses, close parentheses, start brackets, and here's what we're going to do if the user's an admin, right?
That would be a normal programming language.
Ruby doesn't do it like that.
Ruby boils almost all of it away.
We start with the if.
Okay, that's the same.
No parentheses necessary because there's no ambiguity for the human to distinguish that the next part is just a single statement.
So you do if space user dot admin question mark.
No open brackets, no parentheses, no nothing.
Next open line, here's your conditional.
That question mark means nothing to the computer, but it means something to the human.
Ruby put in the predicate method style purely as a communication tool between humans.
It's actually more work for the interpreter to be able to see that this question mark is there.