Ruby - What is the use of super in Ruby Rails?

What is the use of super in Ruby Rails?

The function super is used to invoke the original method, searching of the method body starts in the super class of the object that was found to contain the original method. The following example depicts the same.
def url=(address)
super (address.blank? || address.starts_with?('http')) ? address : http://#{address}
end

What is the use of super in Ruby Rails?

- Ruby uses the super keyword to call the superclass implementation of the current method.
- Within the body of a method, calls to super acts just like a call to that original method.
- The search for a method body starts in the superclass of the object that was found to contain the original method.
def url=(addr)
super (addr.blank? || addr.starts_with?('http')) ? addr : http://#{addr}
end
Ruby - What is the use of load and require in ruby?
Reuire() loads and processes the Ruby code from a separate file, including whatever classes, modules, methods, and constants are in that file into the current scope......
Ruby - Explain the use of global variable $ in Ruby
If you declare one variable as global we can access any where, where as class variable visibility only in the class.......
Ruby - Difference between nil and false in ruby
False is a boolean datatype, Nil is not a data type........
Post your comment