Created
September 16, 2015 05:28
-
-
Save kamatama41/158db8bf2b0952b9963f to your computer and use it in GitHub Desktop.
デフォルト引数のテスト
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
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