Last active
November 15, 2016 19:02
-
-
Save Marchuck/3814653df69908406380dba6e1a44b85 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rx.Observable.range(1, 100).map(i -> String.valueOf(i).concat( | |
(i % 15 == 0 ? "FizzBuzz" : i % 3 == 0 ? "Fizz" : i % 5 == 0 ? "Buzz" : ""))) | |
.subscribe(System.out::println); | |
OR, more readable: | |
rx.Observable.range(1, 100).map(i -> i + suffixFor(i)).subscribe(System.out::println); | |
... | |
String suffixFor(int i) { | |
return (i % 15 == 0 ? "FizzBuzz" : i % 3 == 0 ? "Fizz" : i % 5 == 0 ? "Buzz" : ""); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment