P
progcat
I am still learning Ruby and I am trying to get something
like this to work and am unsure how.
I know I could do attr_reader to
access "ones" but ones might be an
array, hash, etc.
Is there a way to do something like this:
class Test
def initialize
@try["hashworld"] = 10000
@ones = 1,2,3,4
end
def addit(one,two)
#can code add one + two, from
#inside and outside?
return(one + two)
end
end
tens = 10,20,30,40,50
a = Test.new
p a.addit(ones[1],tens[0]) #prints 12
p a.addit(tens[3],ones[0]) #prints 41
p a.addit(tens[3],try["hashworld"]) #prints 10040
Thanks,
Tom
like this to work and am unsure how.
I know I could do attr_reader to
access "ones" but ones might be an
array, hash, etc.
Is there a way to do something like this:
class Test
def initialize
@try["hashworld"] = 10000
@ones = 1,2,3,4
end
def addit(one,two)
#can code add one + two, from
#inside and outside?
return(one + two)
end
end
tens = 10,20,30,40,50
a = Test.new
p a.addit(ones[1],tens[0]) #prints 12
p a.addit(tens[3],ones[0]) #prints 41
p a.addit(tens[3],try["hashworld"]) #prints 10040
Thanks,
Tom