Hacker News new | past | comments | ask | show | jobs | submit login

Yes, I see || as a wart or crufty. Think about the type signature of || in ruby:

  <Type 1 or Type2> ||(Type1 arg1, Type2 arg2)
but in how many other languages is this?

  boolean ||(arg1, arg2)
C, Java, Objective-C, C++, C#, PHP vs Ruby, Perl, Javascript

If || is used more frequently as a logical operator returning true(1) or false(0) to test logical or (not to be used for assignment), why overload this operator?

Having a separate operator like ?: better shows the intention of the usage. It also resembles the ternary function which has similar functionality.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: