Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (1..100).collect{ x ->
- switch([x % 3, x % 5]) {
- case {it[0] == 0 && it[1] == 0} : return 'FizzBuzz'
- case {it[0] == 0 } : return 'Fizz'
- case { it[1] == 0} : return 'Buzz'
- default : return x.toString()
- }
- }.each{ println it }
Add Comment
Please, Sign In to add comment