Giter Site home page Giter Site logo

for...in loop nitpicks about ruby HOT 7 CLOSED

exercism avatar exercism commented on July 24, 2024
for...in loop nitpicks

from ruby.

Comments (7)

kotp avatar kotp commented on July 24, 2024

So how would you suggest changing the wording? It may be able to be improved.

I would say that most do not use it because they aren't solving problems where the last iterated value is not needed to be kept. Or because of the same reason that people don't tend to use 'or' and 'and' as opposed to || and && especially early on in their development as Rubyists.

I have noticed that as people become more experienced with Ruby they start to use each of these things as intended and where appropriate, because they do see the features and nuances given by each.

And though it can be the source of some weird bugs, I don't think it is the cause of those bugs. The cause is simply not keeping track of your variables.

from ruby.

KaoruDev avatar KaoruDev commented on July 24, 2024

ah yes i forgot to put my suggestion!

Perhaps pointing out the behavior of for..in along with your comment:

And though it can be the source of some weird bugs, I don't think it is the cause of those bugs. The
cause is simply not keeping track of your variables.

would suffice. I suppose another good way is to make a concrete example. i.e.

x = 0
for x in 0..4
end
x #=> 4

vs.

x = 0
(0..4).each do |x|
end
x #=> 0

I argue the reason we don't use for..in is it can change the state of our variables without us realizing it. It's not so obvious.

from ruby.

kytrinyx avatar kytrinyx commented on July 24, 2024

This is a really great distinction. The comment lives here: https://github.com/exercism/rikki/blob/master/comments/ruby/for_loop/for_loop.md

Do you want to take a stab at improving it?

from ruby.

KaoruDev avatar KaoruDev commented on July 24, 2024

ah you found my kryptonite: English! haha I'll take a stab sometime today, thanks for the link =)

from ruby.

kytrinyx avatar kytrinyx commented on July 24, 2024

LOL, I'm happy to tweak once you've given it a first pass :)

from ruby.

KaoruDev avatar KaoruDev commented on July 24, 2024

Closing, address in: exercism/DEPRECATED.rikki#8

from ruby.

kytrinyx avatar kytrinyx commented on July 24, 2024

Yepp, thanks! Also: deployed.

from ruby.

Related Issues (20)

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.