File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ condition is true. The `else` statement is optional.
1010
1111``` rn linenums="1" title="conditional-statements.rn"
1212if true {
13- print("true")
13+ print("true")
1414
1515} else {
16- print("false")
16+ print("false")
1717}
1818```
1919
Original file line number Diff line number Diff line change @@ -19,8 +19,8 @@ Multi-line block comments are wrapped in `#!` … `!#`:
1919
2020``` rn
2121#!
22- This is a
23- multi-line comment.
22+ This is a
23+ multi-line comment.
2424!#
2525var y = 2
2626```
@@ -109,9 +109,9 @@ without creating an instance. Instance access also works.
109109
110110``` rn
111111class MathHelper {
112- static fun square(n) {
113- return n ^ 2
114- }
112+ static fun square(n) {
113+ return n ^ 2
114+ }
115115}
116116
117117print(MathHelper.square(5)) # 25
@@ -136,9 +136,9 @@ an array:
136136
137137``` rn
138138fun sum(...nums) {
139- var total = 0
140- for n in nums { total += n }
141- return total
139+ var total = 0
140+ for n in nums { total += n }
141+ return total
142142}
143143
144144print(sum(1, 2, 3, 4)) # 10
@@ -162,9 +162,9 @@ hashmap:
162162
163163``` rn
164164fun show(***kwargs) {
165- for key in kwargs {
166- print(key + " = " + str(kwargs[key]))
167- }
165+ for key in kwargs {
166+ print(key + " = " + str(kwargs[key]))
167+ }
168168}
169169
170170show(name="Alice", age=30)
@@ -179,11 +179,11 @@ variable is shared — mutations are visible:
179179
180180``` rn
181181fun make_counter() {
182- var count = 0
183- return fun() {
184- count += 1
185- return count
186- }
182+ var count = 0
183+ return fun() {
184+ count += 1
185+ return count
186+ }
187187}
188188
189189const counter = make_counter()
@@ -297,8 +297,8 @@ signature.
297297
298298``` rn
299299fun add(a, b) {
300- "Returns the sum of a and b."
301- return a + b
300+ "Returns the sum of a and b."
301+ return a + b
302302}
303303
304304help(add)
You can’t perform that action at this time.
0 commit comments