Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Also:

    x ||= 1
    x &&= 1
and the various built-in methods from Array, Hash, Enumerable, String etc.


These 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: