Chapter 8 - References

Exercise 1: Softball team

Joe Walsh is having a bad day. He couldn’t convince the newest employee, Lisa Wagner, to join the company softball team, so he had to draft the team mascot to play for tonight’s game instead. And now his program to print the company roster is broken, too.

Here’s the code:

staff = ["Walsh", "Moreno", "Nash", "Cox",
         "Rios", "Jones", "Gupta", "Hayes"]
softball_team = staff

staff << "Wagner"
softball_team << "Zonky the Wonder Squirrel"

puts "Company staff:", staff
print "\n\n"
puts "Company softball team:", softball_team

And here’s the output…

Company staff:
Walsh
Moreno
Nash
Cox
Rios
Jones
Gupta
Hayes
Wagner
Zonky the Wonder Squirrel


Company softball team:
Walsh
Moreno
Nash
Cox
Rios
Jones
Gupta
Hayes
Wagner
Zonky the Wonder Squirrel

“Wagner” isn’t supposed to be listed on the softball team, and “Zonky” isn’t supposed to be on the company staff. Can you fix this?

When you’re ready, have a look at the solution.