Tuesday, November 1, 2011

7L7W - Ruby Days 1 and 2


I joined a 7 langauges in 7 weeks study group started by jocranford and others. The group started on 24th October, but I joined only on yesterday. The language for the first week is Ruby. I have done a fair bit of Ruby and consider myself fairly familiar with Ruby.

I have managed to complete days 1 and 2 of Ruby. The book encourages one to Google, read the API and figure out stuff yourself. I have found this approach really nice because following this has enabled me to learn some stuff I did not know about Ruby.

I have put the code for Day 1 and Day 2 on Github.

Stuff I learned from Day 1 and Day2 (Mostly Day 2):

  • Hash sorting is funny. Hashes get converted to Arrays before being sorted. There are other ways to do stuff.
  • Ruby does not have named params. I realized that I never noticed this because I used hashes.
  • A symbol always have the same object id and symbols are not garbage collected.
  • Enumerable#inject and Enumerable#reduce are the same. And there is no need to pass an initial value.
  • File.owned? - Pretty useful API.


This looks like fun.

No comments:

Post a Comment