From 251752fcfb746462d7d64d08708207724a0c4763 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Wed, 16 Sep 2015 07:15:48 -0700 Subject: [PATCH] Make join() require parentheses without a separator. --- builtin/core.wren | 2 +- doc/site/core/sequence.markdown | 14 +++++++------- src/vm/wren_core.wren.inc | 2 +- test/core/list/join.wren | 2 +- test/core/range/join.wren | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/builtin/core.wren b/builtin/core.wren index dde36fcf..c35e4d1d 100644 --- a/builtin/core.wren +++ b/builtin/core.wren @@ -78,7 +78,7 @@ class Sequence { return result } - join { join("") } + join() { join("") } join(sep) { var first = true diff --git a/doc/site/core/sequence.markdown b/doc/site/core/sequence.markdown index 3a783f3d..0f45ef4e 100644 --- a/doc/site/core/sequence.markdown +++ b/doc/site/core/sequence.markdown @@ -68,17 +68,17 @@ Returns whether the sequence contains any elements. This can be more efficient that `count == 0` because this does not iterate over the entire sequence. -### **join**(sep) +### **join**(separator) -Returns a string representation of the sequence. The string representations of -the elements in the sequence is concatenated with intervening occurrences of -`sep`. +Converts every element in the sequence to a string and then joins the results +together into a single string, each separated by `separator`. -It is a runtime error if `sep` is not a string. +It is a runtime error if `separator` is not a string. -### **join** +### **join**() -Calls `join` with the empty string as the separator. +Converts every element in the sequence to a string and then joins the results +together into a single string. ### **map**(transformation) diff --git a/src/vm/wren_core.wren.inc b/src/vm/wren_core.wren.inc index e9c42ffa..3a81df0e 100644 --- a/src/vm/wren_core.wren.inc +++ b/src/vm/wren_core.wren.inc @@ -80,7 +80,7 @@ static const char* coreModuleSource = " return result\n" " }\n" "\n" -" join { join(\"\") }\n" +" join() { join(\"\") }\n" "\n" " join(sep) {\n" " var first = true\n" diff --git a/test/core/list/join.wren b/test/core/list/join.wren index b94b4d16..b08ea1b4 100644 --- a/test/core/list/join.wren +++ b/test/core/list/join.wren @@ -5,7 +5,7 @@ System.print([].join(",") == "") // expect: true System.print([1, 2, 3].join("")) // expect: 123 // Handle a simple list with no separator. -System.print([1, 2, 3].join) // expect: 123 +System.print([1, 2, 3].join()) // expect: 123 // Does not quote strings. System.print([1, "2", true].join(",")) // expect: 1,2,true diff --git a/test/core/range/join.wren b/test/core/range/join.wren index 46a58beb..80bb6932 100644 --- a/test/core/range/join.wren +++ b/test/core/range/join.wren @@ -1,4 +1,4 @@ var a = 1..3 -System.print(a.join) // expect: 123 +System.print(a.join()) // expect: 123 System.print(a.join(", ")) // expect: 1, 2, 3