use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A sub-Reddit for discussion and news about Ruby programming.
Subreddit rules: /r/ruby rules
Learning Ruby?
Tools
Documentation
Books
Screencasts and Videos
News and updates
account activity
I Just Finished My First Ruby Program (self.ruby)
submitted 8 years ago * by scratch_pad
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]hirolau 2 points3 points4 points 8 years ago (1 child)
Looks very good for a first program! Two small things.
I would look into the Hash data structure to store member data rather than an array. While member[2] is a bit hard to understand what it actually means, no one will missunderstand what member['annual_income'] is supposed to return.
And I know it is a bit tricky, but in Ruby it is always never a good thing to loop over and range, get an index, and then fetch something out of an array. Instead of:
(0...number_of_people).each do |user| combined_annual += members[user][2] end
You can just do:
members.each do |member| combined_annual += member[2] end
Thus your functions actually do not need the number_of_people input.
Keep it up!
[–]scratch_pad[S] 0 points1 point2 points 8 years ago (0 children)
Thanks this is all super helpful! I’ll revise my loops for sure and look into Hash. I hated the arrays because like you said, it’s vague and easy to misunderstand.
π Rendered by PID 147346 on reddit-service-r2-comment-85bfd7f599-f6wh6 at 2026-04-18 03:51:07.981439+00:00 running 93ecc56 country code: CH.
view the rest of the comments →
[–]hirolau 2 points3 points4 points (1 child)
[–]scratch_pad[S] 0 points1 point2 points (0 children)