Timeline for FizzBuzz in Ruby
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 27, 2014 at 20:22 | comment | added | Cary Swoveland |
self is required in the definition of divisible_by . An even simpler example is class Integer; def mod(n); % n; end; end . 4.mod(3) => "n\n" . Do you know the rule that requires self to be explicit here? (Other rules, for example, are that write accessors must include self. and self.class is required to obtain self 's class.)
|
|
Jul 15, 2014 at 8:36 | history | edited | tokland | CC BY-SA 3.0 |
deleted 5 characters in body
|
Jul 14, 2014 at 21:38 | history | edited | tokland | CC BY-SA 3.0 |
added 35 characters in body
|
Jul 14, 2014 at 11:57 | comment | added | tokland |
@Flambino. Yes, it's not clear it would be better. But I think it would be more modular, at least (and more functional). First, you get the result (lines ). Now what do you want? printing them? ok, then print_lines(lines) or whatever.
|
|
Jul 14, 2014 at 11:55 | comment | added | Flambino |
+1 for the divisible_by? method from me too. Was considering the same thing (actually, I went looking for such a method in a while back, figuring it might already be built in, but nope). Don't know if I'd find the .lazy.map construction more declarative, compared to a simple each , though
|
|
Jul 14, 2014 at 11:40 | history | edited | tokland | CC BY-SA 3.0 |
added 47 characters in body
|
Jul 14, 2014 at 11:18 | history | edited | tokland | CC BY-SA 3.0 |
added 4 characters in body
|
Jul 14, 2014 at 11:11 | history | edited | tokland | CC BY-SA 3.0 |
added 57 characters in body
|
Jul 14, 2014 at 11:04 | history | answered | tokland | CC BY-SA 3.0 |