From e754fcc49f8de3aef660790af3a731873634b823 Mon Sep 17 00:00:00 2001 From: Gavin Schulz Date: Sat, 4 Apr 2015 15:23:16 -0700 Subject: [PATCH 1/4] Add docs for list.insert. --- doc/site/core/list.markdown | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/doc/site/core/list.markdown b/doc/site/core/list.markdown index 89961168..f3204bef 100644 --- a/doc/site/core/list.markdown +++ b/doc/site/core/list.markdown @@ -21,7 +21,19 @@ The number of elements in the list. ### **insert**(index, item) -**TODO** +Inserts the `item` at the `index` in the list. + + :::dart + var list = ["a", "b", "c", "d"] + list.insert(1, "e") + IO.print(list) // "[a, e, c, d]". + +Returns the inserted item. + + :::dart + IO.print(["a", "c"].insert(1, "b")) // "b". + +It is a runtime error if the index is not an integer or is out of bounds. ### **iterate**(iterator), **iteratorValue**(iterator) From 1cd83eccbc9021aa6149f9074827e1ccde549c9a Mon Sep 17 00:00:00 2001 From: Gavin Schulz Date: Sat, 4 Apr 2015 15:29:10 -0700 Subject: [PATCH 2/4] Add docs for fn.call. --- doc/site/core/fn.markdown | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/site/core/fn.markdown b/doc/site/core/fn.markdown index 6677be39..0549a64c 100644 --- a/doc/site/core/fn.markdown +++ b/doc/site/core/fn.markdown @@ -30,4 +30,13 @@ The number of arguments the function requires. ### **call**(args...) -**TODO** +Invokes the function with the given arguments. + + :::dart + var fn = new Fn { |arg| + IO.print(arg) + } + fn.call("Hello world") // Hello world. + +It is a runtime error if the number of arguments given does not equal the arity +of the function. \ No newline at end of file From d0bebbd38018922507b97c9b517e1f0bfc0c5b2a Mon Sep 17 00:00:00 2001 From: Gavin Schulz Date: Sat, 4 Apr 2015 16:50:40 -0700 Subject: [PATCH 3/4] Add docs for fiber.call. --- doc/site/core/fiber.markdown | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/doc/site/core/fiber.markdown b/doc/site/core/fiber.markdown index b93d0095..8f9f3c87 100644 --- a/doc/site/core/fiber.markdown +++ b/doc/site/core/fiber.markdown @@ -75,11 +75,29 @@ Similar to `Fiber.yield` but provides a value to return to the parent fiber's ### **call**() -**TODO** +Invokes the fiber or resumes the fiber if it is in a paused state. + + :::dart + var fiber = new Fiber { + IO.print("Fiber called") + Fiber.yield() + IO.print("Fiber called again") + } + fiber.call() + fiber.call() ### **call**(value) -**TODO** +Invokes the fiber or resumes the fiber if it is in a paused state and sets +`value` as the returned value of the fiber's call to `yield`. + + :::dart + var fiber = new Fiber { + var value = Fiber.yield() + IO.print(value + 1) + } + fiber.call() + fiber.call(1) // 2. ### **isDone** From c3497ee840b767fc918d7a6945768b7de82b1c33 Mon Sep 17 00:00:00 2001 From: Gavin Schulz Date: Sun, 19 Apr 2015 13:32:15 -0700 Subject: [PATCH 4/4] Code review changes. --- doc/site/core/fn.markdown | 5 +++-- doc/site/core/list.markdown | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/site/core/fn.markdown b/doc/site/core/fn.markdown index 0549a64c..bbbbc404 100644 --- a/doc/site/core/fn.markdown +++ b/doc/site/core/fn.markdown @@ -38,5 +38,6 @@ Invokes the function with the given arguments. } fn.call("Hello world") // Hello world. -It is a runtime error if the number of arguments given does not equal the arity -of the function. \ No newline at end of file +It is a runtime error if the number of arguments given is less than the arity of +the function. If more arguments are given than the arity of the function they +will be discarded. \ No newline at end of file diff --git a/doc/site/core/list.markdown b/doc/site/core/list.markdown index f3204bef..a4577028 100644 --- a/doc/site/core/list.markdown +++ b/doc/site/core/list.markdown @@ -26,7 +26,7 @@ Inserts the `item` at the `index` in the list. :::dart var list = ["a", "b", "c", "d"] list.insert(1, "e") - IO.print(list) // "[a, e, c, d]". + IO.print(list) // "[a, e, b, c, d]" Returns the inserted item.