Conversation
|
About the Struct syntax: When you use the inheritance syntax, you end up with what is known as an “anonymous class” when you inspect the classes inheritance chain. Does this matter? Nah, not really. Is this pedantic? Most definitely. So why do I CARE? Something you have to pick sides, and I choose non-anonymous-classes. |
Really, it's defining the interface... so, if you have a passenger that has a train, all I mean is that the following is a valid "interface". passenger.trainSo, that means, in the context of this exercise, that you: Train = Train.new(all,the,train,stuff)
Passenger = Struct.new(name, train)
train = Train.new(stuff,goes,here)
passenger = Passenger.new("Phil Jo", train)
passenger.train
=> trainDoes that make anymore sense? And this is the perfect place for these discussions. Alternatively, the mailing list. |
There was a problem hiding this comment.
that's a nice use of meta-programming. It'll come in handy later.
attribute.to_s.capitalize.gsub('_',' ')
Two questions actually!
First is that you said at the end of the video we could ask you if we wondering why you prefer the class X < Struct syntax over X = Struct.new, I'd love to hear why!
Also, I wasn't sure what creating a passenger that has a train meant? I've been working with RoR for the past week and all I can think of is :train :belongs_to :person, I know I'm overcomplicating it so could you just explain a little more what you're asking? Thanks so much! (Also if the pull request comment section isn't the proper place for this just let me know where it should go in the future!)