Hacker News new | ask | show | jobs
by luiz-pv9 3780 days ago

  if x.in? my_set   # very ugly
I guess we disagree there. This is arguably more readable than most languages with `in?` being still just a method.
1 comments

I agree, I quite like it as a method as it keeps its congruence with .include? as an opposite of .in? (what .in? does should have been what .include? did from the get go).

Perhaps another way of doing this is calling the method .within?

Seconded. One of the ways in which I prefer Ruby to Python is the way that it always favours "plain methods" over "syntax that maps to special methods under the covers".
But that's not true, as far as I can tell. Ruby does allow you to write 5.+(8), but as far as I can tell most people prefer 5+8. Ruby also has special syntax for <, == and indexing arrays. What things does Python have special syntax for that Ruby doesn't? Off the top of my head I can only remember "in".