Skip to content

Patil's Assignment#2#2

Open
var114 wants to merge 2 commits into
RubyoffRails:masterfrom
var114:master
Open

Patil's Assignment#2#2
var114 wants to merge 2 commits into
RubyoffRails:masterfrom
var114:master

Conversation

@var114

@var114 var114 commented Aug 7, 2013

Copy link
Copy Markdown

No description provided.

Comment thread train.rb

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@jwo

jwo commented Aug 8, 2013

Copy link
Copy Markdown
Member

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!

@var114

var114 commented Aug 8, 2013

Copy link
Copy Markdown
Author

A struct felt ugly wait do you mean just passing in all the variables?

Passenger = Struct.new(:train, :names)
passenger = Passenger.new( {city 'Austin', engine 2, cars 5, caboose 1} , ['Harry'] )

Like this?
On Aug 7, 2013, at 7:04 PM, Jesse Wolgamott notifications@github.com wrote:

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!


Reply to this email directly or view it on GitHub.

@jwo

jwo commented Aug 8, 2013

Copy link
Copy Markdown
Member

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'])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants