On Wed, 2006-06-14 at 00:03 +1000, Graham Smith wrote:

Matt asked us to comment on each others code... so I'll be the first mug
to do so ;-)


> #!/usr/bin/ruby
> 
> amount=ARGV[0].to_f
> 
> x = amount % 5.0
> y = amount - x
>  
> puts x >  2.0 ? y+5 : y 

This is very elegant, but I imagined myself reading through 1000 lines
of code a year after writing it and having to figure out what it means.
Am I being too precious? Am I showing my lack of intimacy with Ruby
code? I've tried to rewrite so that I could read it easily and hopefully
not lose any efficiency:



#!/usr/bin/ruby
amount=ARGV[0].to_f
round = amount % 5
adjusted = amount - round
if round > 2   then    puts adjusted + 5    else puts adjusted    end


_______________________________________________
coders mailing list
coders@slug.org.au
http://lists.slug.org.au/listinfo/coders

Reply via email to