This article is related to Part 6 of the Special Lecture on Multiscale Simulation. We will proceed according to Chart type Ruby.
This time, we will learn about Ruby variables and methods according to Chart expression ruby-II (variable and method).
Ruby
Ruby doesn't require type declarations for variables, so you can use it this way as well.
x = 'Ruby'
x = 19
x = false
You can also assign ARGV [0]
to a variable as in Last article.
name_variable.rb
name = ARGV[0]
puts "hello #{name}"
> ruby name_variable.rb W
-> hello W
Function
in Ruby means to define method
.
This seems to be because everything in Ruby is an object.
Use your hands to remember.
hello_method.rb
def hello name
puts "Hello #{name}."
end
name = ARGV[0]
hello(name)
> ruby hello_method.rb W
-> Hello W.