Today i began the Seven Languages in Seven Weeks challenge. The first week is Ruby.
I know Ruby well so it wasn’t difficult for me. But to my great joy, my partner decided to study along with me, so i had the privilege of witnessing a newcomer’s approach to Ruby.
Together we learnt a bit about the syntax of Ruby: variables, conditions, loops, and a few of the things that make Ruby special, such as: Everything is an object, including numbers and even true and false. We then learned a bit about converting objects from one type to another, and duck typing: if it walks like a duck and quacks like a duck then it’s a duck.
I took a back-seat on the exercises and allowed my partner (who isn’t a programmer) to try out some ideas. I had to smile at the attempt to use a goto:
I said, “I can’t fault your logic – it’s perfect! But we don’t program like that anymore!”
You can see our final soution here: week1-ruby/day1.rb
As Stuart pointed out, we could also have used recursion … “But that’s going a bit too far, don’t you think?” (bonus points for a Mary Poppins reference?!)
How did everyone else get on today? In Ruby i feel qualified to answer questions about the language, so feel free to ask me. I’m certainly going to be needing to ask questions in later weeks!