A
Arfon Smith
Hi, I'm sorry to be asking such a daft question but I need a concept
explaining....
I'm working through the excellent Chris Pine book 'Learn to program' and
I don't get one of the examples he gives. In particular I don't follow
the following example:
def say_moo number_of_moos
puts 'mooooooo...' * number_of_moos
'yellow submarine'
end
x = say_moo 3
puts x.capitalize + ', dude...'
puts x + '.'
Now the output from this is:
mooooooo...mooooooo...mooooooo
Yellow submarine, dude...
yellow submarine
-------------
OK, so here's the problem, I _don't_ get why it doesn't return the
following:
mooooooo...mooooooo...mooooooo
Yellow submarine, dude...
mooooooo...mooooooo...mooooooo
yellow submarine
-------------
Why do we get one set of 'moos' but not a second?
Sorry for such a newbiee question.
Cheers
arfon
explaining....
I'm working through the excellent Chris Pine book 'Learn to program' and
I don't get one of the examples he gives. In particular I don't follow
the following example:
def say_moo number_of_moos
puts 'mooooooo...' * number_of_moos
'yellow submarine'
end
x = say_moo 3
puts x.capitalize + ', dude...'
puts x + '.'
Now the output from this is:
mooooooo...mooooooo...mooooooo
Yellow submarine, dude...
yellow submarine
-------------
OK, so here's the problem, I _don't_ get why it doesn't return the
following:
mooooooo...mooooooo...mooooooo
Yellow submarine, dude...
mooooooo...mooooooo...mooooooo
yellow submarine
-------------
Why do we get one set of 'moos' but not a second?
Sorry for such a newbiee question.
Cheers
arfon