alexloh
alexloh

Reputation: 1616

Ruby ternary operator method name?

What is the name of the method corresponding to the ternary operator? By name I mean :+ for addition, :== for equality, etc.

I want to override the ternary operator to build a proxy class (same idea as Javascript proxies) but I can't seem to find the name for this.

Upvotes: 0

Views: 117

Answers (3)

Linuxios
Linuxios

Reputation: 35788

If you mean symbol, I'd call it:

?:

(Question mark, Colon)

Upvotes: 0

vgoff
vgoff

Reputation: 11323

There are two names that this is known by, if you are talking about the ? : operator, and that is ternary operator or conditional operator.

But it is not a method, as you can see in this table.

You would need to go to Ruby Source itself to override the behavior. Probably not what you would want to do.

Upvotes: 3

Dolphiniac
Dolphiniac

Reputation: 1802

I'm pretty sure it's just known as the ternary operator. Usually people know what you mean when you say that, and I've never heard or seen another name, even during research.

Upvotes: 1

Related Questions