I’m a big fan of English-like programming syntax. I love that Ruby has an unless
operator and that both it and if
can be put after the statement, like
do_this if this
or
do_this unless that
. I also like Javascript’s this
word. I’d like to see all the prepositions in English utilized. How about a neither … nor expression syntax?
Okay, so the thing I want at the moment is demonstrative pronouns. We’re always testing a variable and then doing something with that variable. That sounds like that. How about this, then?
if hash[:key][:another_key] == "some value"
puts hash[:key][:another_key]
end
#vs.
if hash[:key][:another_key] == "some value"
puts that
end
Granted, you could just assign the long value lookup to a variable, which gives more readable code. In fact, hell, you should always do this. I still want this construct. I can be talked out of it, though. What I’m more hot for is this construct:
$variable = $blah["key"]["another_key"] ? $blah["key"]["another_key"] : "default value";
# vs.
$variable = $blah["key"]["another_key"] ? same : "default value";
Cuz repeating the tested variable in a ternary just feels stupid, even when you’re using a well-named variable, amiright?