I have got a function like this–
Function’s name is seld.is_dl and it is accepting path parameter. My question is that what does this ? sign in the function definition indicate.
def self.is_dl?(path)
path = File.basename(path)
if path =~ /setup.exe/i
return false
else
return true
end
end
I am java developer and I have seen “?” in case of If-ELSE block mainly, that is why I am not able to figure what does this mean?
?is a valid character in a method name.It is typically used to denote a method that returns
trueorfalseFor example:
Note:
!is also a valid character. It is typically used to denote a “destructive” methodIf you’re feeling like going the extra mile, Ruby technically allows any string to be a method name. Odd ones need
define_method()andsend()calls, but formally there’s no restriction.