Code practicing from Ruby Programming book