Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
26475d0a
Commit
26475d0a
authored
Nov 25, 2018
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update `doc/limitations.md` for argument destructuring.
parent
762f682b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
1 deletion
+21
-1
doc/limitations.md
doc/limitations.md
+21
-1
No files found.
doc/limitations.md
View file @
26475d0a
...
@@ -219,7 +219,7 @@ $ ruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
...
@@ -219,7 +219,7 @@ $ ruby -e 'def m(*r,**k) p [r,k] end; m("a"=>1,:b=>2)'
[[{"a"=>1}], {:b=>2}]
[[{"a"=>1}], {:b=>2}]
```
```
#### mruby []
#### mruby [
mruby 2.0.0
]
```
```
$ ./bin/mruby -e 'def m(
*r,*
*
k) p [r,k] end; m("a"=>1,:b=>2)'
$ ./bin/mruby -e 'def m(
*r,*
*
k) p [r,k] end; m("a"=>1,:b=>2)'
...
@@ -227,3 +227,23 @@ trace (most recent call last):
...
@@ -227,3 +227,23 @@ trace (most recent call last):
[0] -e:1
[0] -e:1
-e:1: keyword argument hash with non symbol keys (ArgumentError)
-e:1: keyword argument hash with non symbol keys (ArgumentError)
```
```
## Argument Destructuring
```
ruby
def m(a,(b,c),d); p [a,b,c,d]; end
m(1,[2,3],4) # => [1,2,3,4]
```
Destructured arguments (`b` and `c` in above example) cannot be accessed
from the default expression of optional arguments and keyword arguments,
since actual assignment is done after the evaluation of those default
expressions. Thus:
```
ruby
def f(a,(b,c),d=b)
p [a,b,c,d]
end
f(1,[2,3])
```
CRuby gives `[1,2,3,nil]`. mruby raises `NoMethodError` for `b`.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment