Skip to content

Commit 5bd119d

Browse files
committed
Add usage to readme.
1 parent 1e767fb commit 5bd119d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ Gradle:
4646
compile 'com.github.javadev:underscore:1.35'
4747
```
4848

49+
### Usage
50+
51+
```java
52+
U.chain(/* array | list | set | map | anything based on Iterable interface */)
53+
.filter(..)
54+
.map(..)
55+
...
56+
.sortWith()
57+
.forEach(..);
58+
U.chain(value1, value2, value3)...
59+
U.range(0, 10)...
60+
61+
U.chain(1, 2, 3) // or java.util.Arrays.asList(1, 2, 3) or new Integer[] {1, 2, 3}
62+
.filter(v -> v > 1)
63+
// 2, 3
64+
.map(v -> v + 1)
65+
// 3, 4
66+
.sortWith((a, b) -> b.compareTo(a))
67+
// 4, 3
68+
.forEach(System.out::println);
69+
// 4, 3
70+
```
71+
4972
Underscore-java is a java port of [Underscore.js](http://underscorejs.org/).
5073

5174
In addition to porting Underscore's functionality, Underscore-java includes matching unit tests.

0 commit comments

Comments
 (0)