on master help sign in
add documentation for `=?` rune
59f4663Joshua Reagan
docs/hoon/rune/tis/wut.mdnew file+40
@@ -0,0 +1,40 @@
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+=. a ?. =(b c) a c
16+```
17+
18+## Syntax
19+
20+Regular: *4-fixed*.
21+
22+## Discussion
23+
24+Use `=?` to replace the value of leg `p` with `r` on condition `q`. As
25+usual, we are not actually mutating the subject, just creating
26+a new subject with a changed value. The change in value includes a
27+type check against the old subject; the type of `r` must nest under
28+the type of `p`.
29+
30+## Examples
31+
32+```
33+> =a 12
34+
35+> =?(a =(1 1) 22 a)
36+22
37+
38+> =?(a =(1 2) 22 a)
39+12
40+```