Conditional logic in functions

When defining a class method in ruby, you can put conditional logic around the function declaration. This allows you to define separate methods based on your environment.

Example:

if VERBOSE
def trace(message)
puts message
end
else
def trace(message)
print “.”
end
end

Leave a Comment

You must be logged in to post a comment.