1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

R6.org

Last updated at Posted at 2020-12-23

!Mac OS X-10.15.7 !ruby-2.7.1p83

第6回

チャート式Rubyの第2回目変数とメソッドについて

受け取った引数を変数に代入し表示するプログラム

name = ARGV[0]
puts "Hello, #{name}"

上記のコードを実行してみる

> ruby name_variable.rb Rudy
Hello, Rudy

メソッド

def hello(name)
  puts "Hello #{name}."
end
name = ARGV[0]
hello(name)

こちらのコードも実行してみる

> ruby hello_methd.rb Rudy
Hello Rudy

TDD

こうしたcoding方法はTDD(テスト駆動開発)というらしい手順としては・テストを作る・エラーバーを出す・エラーをなくす・リファクタリング

参考サイト

チャート式ruby-ll


  • source ~/grad_members_20f/members/skona/memo/R6.org
1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?