Is there a tutorial that teaches common Ruby programming idioms used by experienced programmers, but may not be obvious to newcomers? [closed]

StackOverflow https://stackoverflow.com/questions/85916

  •  01-07-2019
  •  | 
  •  

Question

I'm looking for a Ruby's equivalent of Code Like a Pythonista: Idiomatic Python

Desirable features:

  • easy to read
  • single document which covers all topics: tips, tricks, guidelines, caveats, and pitfalls
  • size less than a book
  • idioms should work out of the box for the standard distribution (% sudo apt-get install ruby irb rdoc)

Please, put one tutorial per answer if possible, with an example code from the tutorial and its meaning.

UPDATE:

These are the most closest to the above description resources I've encountered:

Was it helpful?

Solution

Ruby Idioms (originally from RubyGarden) is my usual reference for idioms. It's clearly organized and fairly complete. As the author says, these are from RubyGarden, which used to be really cool (thanks Wayback Machine). But now seems to be offline.

OTHER TIPS

Here's a slideshow: Idiomatic Ruby.

Excerpt:

'until' works like 'while not'

  x = x * 2 until x > 100

I would suggest the perennial classic: Why's Poignant guide

It's both an introduction to Ruby and an investigation into the Ruby Way.

Check out The Ruby Way and The Rails Way, they aren't tutorials but I think they will cover what you're looking for.

While not directly a tutorial, here is a blog that you'll find on topic

http://its.arubything.com/

How about Mr. Neigborly's Humble Little Ruby Book

Excerpt:

IO.foreach("textfile.txt") {|line| puts line }

An executable guide to understanding Ruby's closures, closures-in-ruby.rb.

I found this blog recently. Haven't really got into it yet and the couple of posts I have read were a bit beginner focussed. YMMV

http://blog.rubybestpractices.com/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top