On 12 July 2015 at 18:41, Richard Zanabria <lists@ruby-forum.com> wrote:
>
> def calcular_neto(i)
> for i in 0 ..i
> (auto)*0.18
First I suggest that you could use puts within your code to try and
work out exactly which bit of code is not working. Usually you will
then see your mistake, otherwise you can come back and explain exactly
the problem. In this case you did not even tell us what was
happening. In this case you could output the value of i and check
that the result of the calculation is what you expect.
Secondly, though we have determined that it is ok to use accessor
methods when reading a variable within a member method I suggest that
you would be much better to use @auto here, what is the point in
wasting processor time calling the accessor method? Also it is clearer
for the reader to see exactly what you are doing.
Thirdly what is for i in 0..i supposed to do? Iterate i through the
values 0 to i?
Fourthly it is normal to do something with the result of a calculation
rather than just calculating it and ignoring the answer.
Fifthly I suggest you work right through a ruby tutorial. I am sure
there are many on the web.
Sixthly this is a Ruby on Rails list, questions are generally supposed
to have some relevance to Rails applications. I think there are
specific Ruby lists/forums if you are not using Rails.
Seventhly...THERE IS NO SEVENTHLY.
Colin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLvPhM%3DSQSatqKuoLdA4xYQHaP5vjKdp2rPNyDcHs8mdUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment