Merge pull request #318 from urbit/joshuareagan-patch-5
add documentation for `=?` rune
commitec6995166b28a7db68762e5298977b89d4fd9610
authorJoshua Reagan <joshuareagan@users.noreply.github.com>
dateWed 5 Sep 2018, 20:25 (8 years ago)
parent0a1703a1b3790f
docs/hoon/rune/tis/wut.mdnew file+41
@@ -0,0 +1,41 @@
1+---
2+navhome: /docs/
3+next: true
4+sort: 13
5+title: =? "tiswut"
6+---
7+
8+# `=? "tiswut"`
9+
10+`[$tswt p/wing q/hoon r/hoon s/hoon]`: conditionally change one leg in the subject.
11+
12+## Expands to
13+
14+```
15+=. p ?:(q r p)
16+s
17+```
18+
19+## Syntax
20+
21+Regular: *4-fixed*.
22+
23+## Discussion
24+
25+Use `=?` to replace the value of leg `p` with `r` on condition `q`. As
26+usual, we are not actually mutating the subject, just creating
27+a new subject with a changed value. The change in value includes a
28+type check against the old subject; the type of `r` must nest under
29+the type of `p`.
30+
31+## Examples
32+
33+```
34+> =a 12
35+
36+> =?(a =(1 1) 22 a)
37+22
38+
39+> =?(a =(1 2) 22 a)
40+12
41+```