Progate learning notes Write a conditional expression in the return value of the method so that the truth is returned.
def shipping_free?(price)
return price >= 3000
end
** Methods that return a boolean value have the convention of adding a "?" To the end of the method name. ** ** This method is true if the price is 3000 or higher, Returns false if price is less than 3000
When incorporated in an if statement, it looks like this
if shipping_free?(4000)
puts "Free shipping."
else
puts "A shipping fee of 500 yen will be charged."
end
The result of executing this is
Free shipping.
``
---
reference:[Progate](https://prog-8.com)
Recommended Posts