best-ruby
best-ruby copied to clipboard
Ruby Tricks, Idiomatic Ruby, Refactoring and Best Practices
Typo found have been updated
The `if` is actually an expression in the Ruby language. So I would like to correct the statement. ref: https://docs.ruby-lang.org/en/master/syntax/control_expressions_rdoc.html
As started [here](https://github.com/franzejr/ruby-tricks/issues/8). We should probably have categories for a bunch of tricks. We may start using some categories, such as: https://youtu.be/aBgnlBoIkVM?t=2m29s
So far, we just have one best practice for pure Ruby. Looking forward to see more best practices.
In "Idiomatic Ruby / Combine..." the first statement is extraneous. ``` hash = {} # not needed, even misleading values.inject({}) do |hash, value| hash.merge(value => value ** 2) end ```...
The chapter on combining objects suggests that reduce and inject are different methods for different tasks.