Let's actually write the code of ruby. This time is the second.
Substitute the received argument ARGV [0] into a variable called name and write a code to issue it. (Issues in https://qiita.com/daddygongon/items/c51f3e0695174bb3c508)
name = ARGV[0]
puts "Hello #{name}."
Nothing to say about the code itself. By the way, it seems that you don't need a type declaration.
> ruby hello_method.rb Rudy
Hell Rudy.
Create a hello method that returns. (Issues at the link above)
#!/usr/bin/env ruby
def hello name
puts "Hello #{name}."
end
name = ARGV[0]
hello name
method can be written with def-end
.
The argument ()
can be omitted.
There is a story about TDD (Test Driven Development) in the previous link (here). Let's read it.
Chart type ruby-II (variable and method)
Recommended Posts