Skip to content

Comment on The Groovy project is looking for a new homeparent

Comments

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.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.