Giter VIP home page Giter VIP logo

best-ruby's Introduction

Hi there ๐Ÿ‘‹

best-ruby's People

Contributors

0x0dea avatar abarrak avatar alebian avatar ciaoben avatar dansandland avatar eftakhairul avatar ezekg avatar filipebarcos avatar franzejr avatar fredkelly avatar gitter-badger avatar ilyaumanets avatar jadercorrea avatar josephgrossberg avatar jtmarmon avatar latortuga avatar lightyrs avatar marceloboeira avatar marcosx avatar matugm avatar peterwilson avatar rafaelsales avatar sagareganesh avatar sergii avatar shadefinale avatar skylerrogers avatar sojinsamuel avatar taw avatar tdkn avatar xzgyb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

best-ruby's Issues

Add more Best Practices

So far, we just have one best practice for pure Ruby.

Looking forward to see more best practices.

Display all options list in README.

Hi,
It will be better if we display all options list in README like faker gem.
There are 2 advantage of this

  1. Easy to understand.

  2. Decrease one step in search engine.

    Is it make sense?
    thoughts?

    I can create PR, just let me know

Fixnum#times

On the page addressing Fixnum#times you state that the developer should favor for loops over Fixnum#times. We generally avoid for loops in Ruby and I've often heard people argue that they should be removed entirely. I think an entire section discussing looping in Ruby would be appropriate. There you could mention that we stay away from for.

The file in question.

Why not put together?

Hi, It seems more convenient to read them in a row without opening each file. What do you think?

Suggestion for inject

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

In older versions of ruby, the hash var would collide with the block arg; in modern ruby, they're scoped, so the hash being injected is the {} arg to inject, not the variable.

A more idiomatic version might be:

result = values.inject({}) do |hash, value|
  hash.merge(value => value ** 2)
end 

It would also be useful to note that the use of merge with inject is a bit tricky, and only works because merge returns the hash itself. If the last expression in the block doesn't return the injected value, the inject will fail in weird ways. A less error-prone way to code it is to always return the injected value:

result = values.inject({}) do |hash, value|
  hash[value] = value ** 2
  hash
end

or, as a one-liner:

result = values.inject({}) {|hash, value| hash[value] = value ** 2; hash}

Inner assignment conditional is a pretty bad example...

Why would you ever do

retval = if vals.any?
           do_something(vals)
         else
           do_something_different
         end

over

retval = vals.any? ? do_something(vals) : do_something_different

I think the inner assignment conditional only makes sense when more logic needs to be performed inside the conditions

(head, *tail)

I don't know if this is "tricky" enough but I thought this was cool

(head, *tail) = array # break off the first element of the array, and keep the rest separately

source

best-ruby/idiomatic_ruby/each_vs_map.md

This code:

users_ids = users.map &:id

Is anything but idiomatic. Something like this:

users_ids = users.map(&:id)

would look like proper Ruby.

Freely floating &: just looks weird.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.