You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ruby Tricks, Idiomatic Ruby, Refactorings and Best Practices
Do you know why experienced Ruby programmers tend to reach for basic collections
and hashes while programmers from other languages go for more specialized classes?
Do you know the difference between strip, chop, and chomp; and why there are three
such similar methods when apparently one might suffice (Not to mention lstrip and
rstrip!)? Do you know the downsides of dynamic typing? Do you know why the differences
between strings and symbols get so blurry, even to experienced Ruby developers?
How about metaprogramming? What the heck is an eigenclass? How about
protected methods? Do you know what they’re really about? Really? Are you sure?
Eloquent Ruby
Absolutely the best way to learn to write idiomatic Ruby code is to read idiomatic Ruby code. Eloquent Ruby
This repository aims to help everyone write more idiomatic, clean, and tricky ruby code and also document good refactoring techniques. You can add your own technique or paste it from some website. Do not forget the source, of course. All the tricks are in the /tricks folder.
For the sake of clarity, you should paste in the markdown format. At the end, if the code is not your own, paste a reference to the author and source of the technique.
You can write Ruby code, but it can sometimes look like Java code. Here you can find some tips to write more naturally and take advantage of idiomatic Ruby.
Small (and big) improvements you can apply to your code and improve it's readability and maintenance. Change the internal structure of the code without changing it's behaviour.
If you keep your house cleaned constantly you'll never need to waste a weekend cleaning it. The same applies to your code. Be disciplined and keep your code looking good with those tips.