[Ruby] methods, instance methods, etc ...

Progate learning notes Get confusing

Method

What is written like this.

def info
  #processing
end

Instance method

Methods defined in the class and called for the instance

#Menu class
class Menu
  # recommended_A class method called menu
  def recommended_menu(name)
    return "Today's recommendation#{name}is."
  end
end

#instance
menu = Menu.new

#Recommended for the instance_Call the menu method
puts menu.recommended_menu("Meita bread")

Execution result ↓

Today's recommendation is menta bread.

Reference: Progate

Recommended Posts

[Ruby] methods, instance methods, etc ...
[Ruby] Class methods, instance methods, etc.
About Ruby instance methods
[Ruby] Classes, instance variables, instances, etc ...
[Ruby] Handle instance variables with instance methods
Ruby Learning # 15 Methods
About Ruby methods
Ruby Learning # 31 Object Methods
About calling instance methods
Ruby variables and methods
[Ruby] About instance generation
Ruby: Differences between class methods and instance methods, class variables and instance variables
Basic methods of Ruby hashes
Basic methods of Ruby arrays
[Self-use memo] (Ruby) class, class instance, instance
Three Bit Manipulation Methods (Ruby)
Instance creation, constructor, field, etc.
[Ruby] What is an instance?
What are Ruby class methods?
[Ruby] Singular methods and singular classes
Ruby variables and functions (methods)
Ruby methods and classes (basic)
[Ruby] Singular methods and singular classes
Write Ruby methods using C (Part 1)
Ruby standard input and various methods
Ruby convenience methods for fledgling engineers
Ruby methods often used in Rails
[Ruby basics] Methods that frequently use blocks
Difference between Ruby instance variable and local variable
Methods that I found useful in Ruby
Ruby methods return the last evaluated value
Write Ruby methods using C (Numo :: NArray)
Write Ruby methods using C ++ (Part 2) Benchmark
Find out about instance methods and self
[Ruby] Difference between methods with and without self in the class. About class methods and instance methods.