You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# In Ruby, you can define default values for method parameters.
# This allows you to call a method without providing all the arguments, and the default values will be used for any missing arguments.
def greet(name = "Guest")
puts "Hello, #{name}!"
end
greet("Luthfi") # Output: Hello, Luthfi!
greet # Output: Hello, Guest!
# But better practice use keyword arguments with default values, because it can make your code more readable and allows you to specify which arguments you are providing when calling the method.
# See the method_keyword_arguments.rb file for more details about keyword arguments with default values.