Ruby - Control Flow
Given the array
nums = [0, 1, 2, 3], which code snippet correctly prints only the non-zero numbers using inline unless?nums = [0, 1, 2, 3], which code snippet correctly prints only the non-zero numbers using inline unless?puts n unless n == 0, which prints n only if n is not zero. nums.each { |n| puts n if n == 0 } prints only zero, which is wrong. nums.each { |n| puts n unless n != 0 } prints only zero because unless n != 0 means if n == 0. nums.each { |n| puts n if n != 0 } prints non-zero numbers but uses inline if, not unless.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions