From: Victor Deryagin Date: 2011-07-24T20:30:54+09:00 Subject: Re: Exclusive operator in ruby "amir e." writes: > 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: def my_func(hsh) hsh = {:a => 0, :b => 1, :c => 2}.merge hsh hsh[:a] + hsh[:b] + hsh[:c] end my_func({:c => 10}) #=> 11