Ruby Idioms

  • Caike

Oops, a subscription is required to view this video. You can enroll now to watch, or try out all that Code School has to offer with a free two-day Hall Pass.


Andy Zhang said

Very clever and compact - I like it!

Rahul Jayaraman said

Awesome! Would love to see more complex Ruby stuff. I liked the duration as well.

Jonathan Ruiz said

That was awesome Caike, Thanks!

mwallisch said

Still new to ruby so maybe I'm missing something... It looks really neat but taking away a classes possibility of inheritance just to save a few lines of code? I don't know, doesn't feel right in terms of flexibilty. Apart from that: very good video!

Mitch said

This is clever and enlightening. Well done.

luciferuk said

One day this will click, but for now I'M PULLING MY HAIR OUT #thatisall

azrad said

Never use Struct before, good tutorial and helps me understand more.

will barker said

Nice. I remember this stuff being tricky in Ruby bits II. Helps to take a new look at it.

Daniel Gerep said

Where are the pitfalls? Abraço!

Alex Braha Stoll said

Interesting idiom, I will try it later! However, I still feel it is better to stick with initialize (only because it is the convention and I don't think there are lots of advantages in using the Struct idiom).


Learn how to use Ruby Structs as class constructors in Ruby. We'll review the benefits and the potential pitfalls of this approach.