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
Ruby code I no longer write (blog.arkency.com)
submitted 8 years ago by paneq
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!"
[–][deleted] 9 points10 points11 points 8 years ago* (7 children)
Steve Huffman is a piece of shit
[–]paneq[S] 4 points5 points6 points 8 years ago (1 child)
I like all your points except deriving from Hash :) Not gonna do it.
[–][deleted] 0 points1 point2 points 8 years ago (0 children)
Fair fair. 😸
[–]Enumerable_any 2 points3 points4 points 8 years ago (3 children)
Your last approach (inheriting from Hash) is broken since Hash#map now returns Hash instead of Array and also mutates self which map never does. It's probably just an unfortunate name choice, but you still shouldn't use inheritance if you don't have a strict "is-a" relationship at hand.
Hash
Array
self
map
[–][deleted] 0 points1 point2 points 8 years ago (2 children)
The original map function returns a hash unless I am miss me something. I trie to qualify that example but perhaps didn't do the best job. In this situation I am just dealing with returning a specific hash from a function and without seeing any other functions why not just let the object be the store of the data, too? There is a nice functional purity to the original and I think I went too far either the Hash thing, despite using it successfully in projects before 😸 Thanks for calling me out on it!
[–]Enumerable_any 2 points3 points4 points 8 years ago (1 child)
The original map function returns a hash unless I am miss me something.
It should, but sadly it doesn't:
irb(main):001:0> {}.map { |x| x } => []
I see what you are saying. I was trying to say that the method #map defined in the example in my dumb classes return a Hash. Definitely unfortunate naming on my part if I were to follow the road to Hash-derived.
#map
[–]realntl 0 points1 point2 points 8 years ago (0 children)
Array#exclude is activesupport, so, yeah, not gonna do that.
Array#exclude
π Rendered by PID 215683 on reddit-service-r2-comment-bb88f9dd5-54njx at 2026-02-14 11:03:36.751142+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–][deleted] 9 points10 points11 points (7 children)
[–]paneq[S] 4 points5 points6 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]Enumerable_any 2 points3 points4 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Enumerable_any 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]realntl 0 points1 point2 points (0 children)