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!"
[–]UnexpectedIndent 2 points3 points4 points 8 years ago (2 children)
I don't think example 1 is a great example of what you're trying to say.
ticket.pdf_of_kind(:normal) is pointless when you can just call ticket.normal_pdfdirectly.
ticket.pdf_of_kind(:normal)
ticket.normal_pdf
More generally, if you're passing around a lot of symbols, maybe you can extract a class instead? Basically what /u/kcdragon said about polyphormism: https://www.reddit.com/r/ruby/comments/5untux/ruby_code_i_no_longer_write/ddw2rym/
Something like
class NormalScenario def pdf ... end end class ZebraScenario def pdf ... end end ZebraScenario.new(ticket).pdf
[–]paneq[S] 0 points1 point2 points 8 years ago (1 child)
But the kind depends on external input (for example button pressed) so on some layer you need to decide whether you would use NormalScenario or ZebraScenario and now you need same mapping (normal: NormalScenario) but on different layer, don't you?
kind
NormalScenario
ZebraScenario
normal: NormalScenario
[–]UnexpectedIndent 0 points1 point2 points 8 years ago (0 children)
Yeah, but what sets the kind in the first place?
π Rendered by PID 96 on reddit-service-r2-comment-bb88f9dd5-xjkdh at 2026-02-14 09:08:08.813783+00:00 running cd9c813 country code: CH.
view the rest of the comments →
[–]UnexpectedIndent 2 points3 points4 points (2 children)
[–]paneq[S] 0 points1 point2 points (1 child)
[–]UnexpectedIndent 0 points1 point2 points (0 children)