Skip to content

Instantly share code, notes, and snippets.

@Marchuck
Last active Nov 15, 2016
Embed
What would you like to do?
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