Ruby - Error Handling
Identify the error in this Ruby code snippet:
def divide(a, b) raise "Cannot divide by zero" if b = 0 a / b end puts divide(10, 0)
def divide(a, b) raise "Cannot divide by zero" if b = 0 a / b end puts divide(10, 0)
b = 0 which assigns 0 to b instead of comparing it. This is a common mistake.b == 0.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions