Hi
I am C++ programmer and I start ruby programming about 1 month.I have 2
questions:
1 - I don't understand what is these operators : === and !== . please
give an example.
2 - As respect , Ruby is very comfort language , can we define function
like this :
def myFunc( a=0 , b=1 , c=2 )
d = a+b+c
end
and call this function with only third argument like :
myFunc( , , 10).
Hi
I am C++ programmer and I start ruby programming about 1 month.I have 2
questions:
1 - I don't understand what is these operators : === and !== . please
give an example.
'Object#===' method is the same as 'Object#==', but is often overridden
by the descendants for convenience (mainly to provide meaningful
semantics in 'case' statements). For example, Regexp class makes it an
alias to its '=~' method, so you can do things like this:
a = "HELLO"
case a
when /^[a-z]*$/; :lower_case
when /^[A-Z]*$/; :upper_case
else; :mixed_case
end #=> :upper_case
(a !== b), as you might expect, is equivalent to !(a === b).
2 - As respect , Ruby is very comfort language , can we define function
like this :
def myFunc( a=0 , b=1 , c=2 )
d = a+b+c
end
and call this function with only third argument like :
myFunc( , , 10).
You can not do this (ruby does not support keyword arguments), but it is
possible to achieve similar result by passing your arguments as hash: