S
Sijo Kg
Hi
I was learing Ruby and have code like
Class TestClass
def getcolors
arr=["Blue","Yellow"]
arr1=["1","2"]
end
end
obj=TestClass.new
puts obj.getcolors
And the result is 1 2 ..This looks some strange to me since
I have not notice in other languages And if arr1=["1","2"] is absent
then it puts Blue Yellow ..So dont we need return .I would like to know
what happens here actually
And another inteesing thing is if I write
return arr=["Blue","Yellow"] the result i get is Blue Yellow
If I give
return arr=["Blue","Yellow"]
return arr1=["1","2"] then also I get "Blue Yellow
Why?
Thanks in advance
Sijo
I was learing Ruby and have code like
Class TestClass
def getcolors
arr=["Blue","Yellow"]
arr1=["1","2"]
end
end
obj=TestClass.new
puts obj.getcolors
And the result is 1 2 ..This looks some strange to me since
I have not notice in other languages And if arr1=["1","2"] is absent
then it puts Blue Yellow ..So dont we need return .I would like to know
what happens here actually
And another inteesing thing is if I write
return arr=["Blue","Yellow"] the result i get is Blue Yellow
If I give
return arr=["Blue","Yellow"]
return arr1=["1","2"] then also I get "Blue Yellow
Why?
Thanks in advance
Sijo