Does ==> have any specific significance?


#1

I just noticed this,

:sasquatch.to_s
# ==> "sasquatch"

"sasquatch".to_sym
# ==> :sasquatch

It looks like ==> is being used as meaning "equals", but I wasn't sure and I'm just guessing really.

Is my guess right?


#2

Will need to dig around to narrow in on this exercise. If you get a minute, and are still interested in finding out more, please post a link to where you noticed this. Thank you.


#3

I'm not aware of any such operator in Ruby. The closest thing to it is the <=> (combined comparison operator). In any event, the greater than > would never be on right side, except for this operator.

>=   greater than or equal to 
<=   less than or equal to

Equality is only determined with == in most cases. In a when clause of a case statement we would use ===.


#4

It isn't any operator or perhaps even remotely related. As you would see when you a repl, like this one, it's just the return value of a particular statement, so like, typing :sasquatch.to_s gives (==>) "sasquatch" and the same for the other statement.

So, that ==> means gives a value.


#5

Perfect thank you! That clears it up!


#6

And, @designslayer73591, note that it isn't any standard "operator" that you would use in any Ruby code. It could also have been written as => depending on author's preference. The nearest guess I can make for this symbols origin is the implies symbol in maths. It is similar to ==> in both shape and meaning.


#7

I was not aware of this, as this looks like associative array syntax, not a comparator. Is there more information in some documentation you can point out, please? Thank you.


#8

There isn't exactly any documentation regarding this because it isn't any operator to be used in code, but as I said, the meaning of ===> as I interpreted it, is most close to what the author could have meant, to imply a value or to give a value.


#9

Again, I repeat...

Valid or invalid?


#10

Oh, you mean, regarding =>, I meant to say that the ==> could have been written as => (and you can see that the repl uses =>) depending on whether the author wanted to use it or not. But certainly the author didn't use it because he might not have wanted it to be confused with Ruby's hash rocket.