3 ms·
Uh.. I'm not sure I like this, in a language that already has a similar boolean operator (although I suppose that goes for all uses of such "arrow" operators).
by e12e 6y ago
Uh.. I'm not sure I like this, in a language that already has a similar boolean operator (although I suppose that goes for all uses of such "arrow" operators). But still:
a = 2
b = 1
b >= a # false
b >= a => a # assign false to a?
b => a # assign 1 to a?
- dragonwriter 6y agoIt already has at least two different uses for the exact sigil "=>" (hash construction, identifying capture variable in a rescue clauses), which is probably more significant than that it has a kinda similar sigil used as a comparison operator. Like natural language (but unlike programming languages constructed with thought toward ease of automated parsing), Ruby syntax is quite context sensitive.
- e12e 6y agoI forgot one, or two: b <= a # true b <= a => b # assign true to b? I'm not too thrilled about the hash-arrow - but I think it's a bit more obvious from context.