Skip to content

Instantly share code, notes, and snippets.

@kamatama41
Created September 16, 2015 05:28
Show Gist options
  • Save kamatama41/158db8bf2b0952b9963f to your computer and use it in GitHub Desktop.
Save kamatama41/158db8bf2b0952b9963f to your computer and use it in GitHub Desktop.
デフォルト引数のテスト
```
irb(main):001:0> def hoge(a=1, b, c=3) a+b+c end
SyntaxError: (irb):1: syntax error, unexpected '=', expecting ')'
def hoge(a=1, b, c=3) a+b+c end
^
from /Users/shinichi/.rbenv/versions/2.2.3/bin/irb:11:in `<main>'
irb(main):002:0> def hoge(b, a=1, c=3) a+b+c end
=> :hoge
irb(main):003:0> hoge 100
=> 104
irb(main):004:0> hoge 100, 3
=> 106
irb(main):005:0> hoge 100, 3, 10
=> 113
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment