Conversation
There was a problem hiding this comment.
mostly, keys like this would be lowercase, like :city
There's nothing wrong with it -- in fact, you can have numbers, strings, objects, classes, anything as your hash keys. But for readability, I'd go with lowercase :city
|
Interesting choice with the train_info being a hash. I was expecting more of a Struct, but the hash works well indeed -- especially later when you iterate over the key/values. Well done! |
|
A struct felt ugly wait do you mean just passing in all the variables? Passenger = Struct.new(:train, :names) Like this?
|
|
Something like: Train = Struct.new(:city :engine, :cars, :caboose)
Passenger = Struct.new(:train, :names)
train = Train.new('austin', 2, 5, 1)
passenger = Passenger.new(train, ['harry']) |
No description provided.