Skip to content

Commit d14a605

Browse files
committed
d updated markdown snippets
1 parent f08b1c4 commit d14a605

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

approvaltests-util/docs/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ A set of convenience functions to make life easier.
77
## Contents
88

99
* [Features](#features)
10-
* [BasicUtils](#basicutils)<!-- endToc -->
10+
* [BasicUtils](#basicutils)
11+
* [Lambdas](#lambdas)<!-- endToc -->
1112

1213
## Features
1314
[New Features documented here](Features.md#top)

approvaltests-util/docs/how_to/UseMutablesInLambdas.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<!-- toc -->
66
## Contents
77

8-
* [Why use logs?](#why-use-logs)
9-
* [Capturing logs in test](#capturing-logs-in-test)
10-
* [See also](#see-also)<!-- endToc -->
8+
* [The problem](#the-problem)
9+
* [Single Element array solution](#single-element-array-solution)
10+
* [Mutable<T> solution](#mutablet-solution)<!-- endToc -->
1111

1212

1313
## The problem
@@ -35,17 +35,44 @@ The most common solution to this is to use a single element array. While this wo
3535

3636
For example:
3737

38-
snippet: single_element_array
38+
<!-- snippet: single_element_array -->
39+
<a id='snippet-single_element_array'></a>
40+
```java
41+
final int[] i = {1};
42+
Function0<Integer> counter = () -> i[0]++;
43+
```
44+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/utils/MutableTest.java#L12-L15' title='Snippet source file'>snippet source</a> | <a href='#snippet-single_element_array' title='Start of snippet'>anchor</a></sup>
45+
<!-- endSnippet -->
3946

4047
## Mutable<T> solution
4148

4249
Mutable allows for easy getting/setting/updating.
4350

4451
For example:
4552

46-
snippet: mutable_example
53+
<!-- snippet: mutable_example -->
54+
<a id='snippet-mutable_example'></a>
55+
```java
56+
Mutable<String> i = new Mutable<>("Brian");
57+
Scheduler scheduler = new Scheduler(() -> i.get());
58+
scheduler.addEvent();
59+
i.update(n -> "Mr. " + n);
60+
scheduler.rsvp();
61+
i.set("Steve");
62+
scheduler.bookHotel();
63+
```
64+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/utils/MutableTest.java#L20-L28' title='Snippet source file'>snippet source</a> | <a href='#snippet-mutable_example' title='Start of snippet'>anchor</a></sup>
65+
<!-- endSnippet -->
4766

4867
Will produce the following:
4968

50-
snippet: MutableTest.exampleOfMutable.approved.txt
69+
<!-- snippet: MutableTest.exampleOfMutable.approved.txt -->
70+
<a id='snippet-MutableTest.exampleOfMutable.approved.txt'></a>
71+
```txt
72+
adding event as Brian
73+
rsvping as Mr. Brian
74+
booking hotel as Steve
75+
```
76+
<sup><a href='/approvaltests-util-tests/src/test/java/org/lambda/utils/MutableTest.exampleOfMutable.approved.txt#L1-L3' title='Snippet source file'>snippet source</a> | <a href='#snippet-MutableTest.exampleOfMutable.approved.txt' title='Start of snippet'>anchor</a></sup>
77+
<!-- endSnippet -->
5178

0 commit comments

Comments
 (0)