Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ruby Tricks (github.com/franzejr)
74 points by franzunix on Nov 1, 2015 | hide | past | favorite | 19 comments


A brief explanation of what some of these are doing, or moreover, a use case for why I would want to use them would be handy.


Indeed! Will do it later! I just started this! Thanks for the feedback!


Only looked at "Fetch Data" and "Bubbling up thread errors" so far, but they were self-explanatory. I'm betting most of them are like this.


Yeah..Some of them are self-explanatory, it makes me to think that the comments/description may not be necessary. But, a simple comment it's not a problem...Let's see. =)


associative arrays could use an example illustrating when/why to use them


I was hoping for something like "static code analysis" and "make code more robust", not for "magic" and "even more magic".


You probably want http://elixir-lang.org that way ==>


$VERBOSE is mentioned for warnings. That's pretty handy.


I also like $DEBUG! =)

if $DEBUG p "var is %p" % var end


One very obscure trick in ruby is the flip-flop operator. Never used it and I probably never will. There's an open issue to get rid of it[1]. Has anyone ever had a real use case for it?

[1]: https://bugs.ruby-lang.org/issues/5400


You've never wanted a range of lines out of a file? It's a common Perl idiom.


It looks like this is not being treated as a range operator, but a flip-flop operator I've never heard of


That's the name of the operator, sure. One of the use cases of the flip-flop operator is selecting a range of lines in a file.


Thanks for sharing this. Love this format. Learned about PStore, cycle, take, fetch, securerandom, and more. May add to it.

Tweeted:

https://twitter.com/sivers/status/660875966466514944


thanks!


Awesome initiative! Already sent my PR :)


thanks, goofed


Sent a PR with a couple of fixes.


thanks, man!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: