3 ms·
I’m not sure what “shortcuts” the author is referring, but perhaps… x = y || z # if y is falsy x = z x = f ? y : z # ternary operator %w{one tw
by transfire 4y ago
I’m not sure what “shortcuts” the author is referring, but perhaps…
x = y || z # if y is falsy x = z
x = f ? y : z # ternary operator
%w{one two three} # array of words
And so on.
- endorphine 4y agoAlso: x ||= 1 x &&= 1 and the various built-in methods from Array, Hash, Enumerable, String etc.
- intuxikated 4y agoThese all exist in python, though you use or/and instead x = y or z x = f and y or z you can also use inline if/else x = y if f else z 3rd one just seems like an array of strings? ["One", "two", "three"] Not needing quotes for single words saves some typing tho.
- deleted 4y ago[deleted]