Skip to content

Commit

Permalink
Describe the difference of the keyword argument behavior.
Browse files Browse the repository at this point in the history
The implementation of keyword arguments is heavily rely on the prototype
made by @take-cheeze in mruby#3629.
  • Loading branch information
ksekimoto committed Jul 30, 2018
1 parent 087edee commit d4be374
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions doc/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,25 @@ trace (most recent call last):
[0] -e:1
-e:1: undefined method 'binding' (NoMethodError)
```

## Keyword arguments

mruby keyword arguments behave slightly different from CRuby 2.5
to make the behavior simpler and less confusing. Maybe in the
future, the simpler behavior will be adopted to CRuby as well.

#### Ruby [ruby 2.5.1p57 (2018-03-29 revision 63029)]

```
$ ruby -e 'def m(*r,**k) p [r,k] end; m("a"'=>1,:b=>2)'
[[{"a"=>1}], {:b=>2}]
```

#### mruby []

```
$ ./bin/mruby -e 'def m(*r,**k) p [r,k] end; m("a"'=>1,:b=>2)'
trace (most recent call last):
[0] -e:1
-e:1: keyword argument hash with non symbol keys (ArgumentError)
```

0 comments on commit d4be374

Please sign in to comment.