Methods (def)
Defining functions with def, parameters, automatic return, and default values.
Simple enough for a 5-year-old to understand
Method with def
Ruby automatically returns the value of the last expression — no need to write return.
def square(x) x * xendputs square(5)🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)
🎯 Expected output: 17