Skip to content

Commit eb497a2

Browse files
committed
Update README.md
1 parent 77ae939 commit eb497a2

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

README.md

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,25 +188,34 @@ The followings are types which can be used to create an *Enumerable* in Multiple
188188
#### - Multiplex Collections
189189
All the collections defined in Multiplex are *Enumerable*, and can be used in LINQ queries:
190190
````javascript
191-
var list = new mx.List([1, 2, 3, 4]); // a list of numbers
192-
var set = new mx.HashSet([1, 2, 3, 4]); // a set of numbers
193-
var dic= list.toDictionary("t => t"); // a dictionary with numeric keys
191+
var list = new mx.List([1, 2, 3, 4]); // a list of numbers
192+
var set = new mx.HashSet([1, 2, 3, 4]); // a set of numbers
193+
var dic = list.toDictionary("t => t"); // a dictionary with numeric keys
194194

195-
list.select("t => t").toArray(); // [1, 2, 3, 4]
196-
set.select("t => t").toArray(); // [1, 2, 3, 4]
197-
dic.select("t => t.key").toArray(); // [1, 2, 3, 4]
195+
list.select("t => t").toArray(); // [1, 2, 3, 4]
196+
set.select("t => t").toArray(); // [1, 2, 3, 4]
197+
dic.select("t => t.key").toArray(); // [1, 2, 3, 4]
198198
````
199199

200200
<br/>
201201
#### - Array and String
202-
Arrays and Strings are enumerable per ser, to make things easy, *Enumerable* methods are applied to JavaScript built-in *String* and *Array* classes, so in short you can use LINQ methods on Array and Strings pretty much the same way you use them on *Enumerable* objects:
202+
*Array*s and *Strings* are *Enumerable* per ser, because they have a default iteration behavior. This means you can pass *String* or *Array* objects to any method accepting *Iterable* argument without wrapping it in an *Enumerable* object.
203+
This comes handy in LINQ operations, so instead of this:
203204

204205
````javascript
205-
[1, 2, 3, 4].select("t => t * t").toArray(); // [1, 4, 9, 16]
206-
"string".select("t => t").toArray(); // ["s", "t", "r", "i", "n", "g"]
206+
mx([1, 2]).union(mx([3, 4])).toArray(); // [1, 4, 9, 16]
207+
mx("str").union(mx("ing")).toArray(); // ["s", "t", "r", "i", "n", "g"]
208+
````
209+
210+
You can write:
211+
212+
````javascript
213+
mx([1, 2]).union([3, 4]).toArray(); // [1, 4, 9, 16]
214+
mx("str").union("ing").toArray(); // ["s", "t", "r", "i", "n", "g"]
207215
````
208216

209217
Note that, in the example above the string object is queried as a sequence of characters.
218+
In practice, LINQ operations accept any argument implementing [ES6 iteration protocols](https://github.com/multiplex/multiplex.js#es6-iteration-protocols).
210219

211220
<br/>
212221
#### - Array-like objects: `arguments`, `NodeList`, `jQuery`

0 commit comments

Comments
 (0)