R
Ryan Allan
Hello Everyone,
I'm trying to make a function take arguments in a particular way.
This is what I want to create:
#Variable argument testing
def function(*sometimes)
if sometimes.nil?
print "Not given!"
else
print "Here!"
end
end
function
[EOF]
As I understand it, the * operator bundles the argument into an array,
so that if test returns true. I know that I can use "if
sometimes.length==0" to get the same behaviour, but that is rather
obscure compared to the first version.
Is there some other way to set up the argument list? (Alas, I have found
nothing in the documentation or the Forum.)
Thank you,
-Ryan
I'm trying to make a function take arguments in a particular way.
This is what I want to create:
#Variable argument testing
def function(*sometimes)
if sometimes.nil?
print "Not given!"
else
print "Here!"
end
end
function
[EOF]
As I understand it, the * operator bundles the argument into an array,
so that if test returns true. I know that I can use "if
sometimes.length==0" to get the same behaviour, but that is rather
obscure compared to the first version.
Is there some other way to set up the argument list? (Alas, I have found
nothing in the documentation or the Forum.)
Thank you,
-Ryan