Skip to content

Commit 0d8a025

Browse files
committed
Readme - Update for variables with spaces.
1 parent 18fec5d commit 0d8a025

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

README.md

+15-18
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ Comments and Documentation
2929

3030
Variables and Types
3131
```
32-
String hello = "Hello, World!"
32+
// Variable names can contain spaces. Yes, really.
33+
String hello world = "Hello, World!"
3334
3435
// Types can be inferred.
35-
is_spring = true
36+
is spring = True
3637
3738
// Types can depend on other types (Generic Types) or on values (Dependent Types).
38-
Int(32) power_level = 9000
39+
Int(32) power level = 9000
3940
4041
fun slice(Array arr, Int index < arr.length) Array(size=index):
4142
// Or more explicitly as slice(Array arr, Int index if index < arr.length)
@@ -55,15 +56,15 @@ Conditions
5556
```
5657
// Informal has just a single conditional operator - the pattern-matching "if".
5758
if sunny:
58-
go_outside()
59+
go outside()
5960
else if rainy:
60-
go_outside_with_umbrella()
61+
go outside with umbrella()
6162
else:
6263
6364
6465
// You can use it as a switch case.
6566
// Conditions are expressions, so you can capture their result and store it as a variable.
66-
char_type = if ch:
67+
char type = if ch:
6768
' ': "ch is a Space"
6869
'a'..'z' | 'A'..'Z': "ch is a Letter"
6970
'0'..'9': "ch is a Digit"
@@ -87,9 +88,9 @@ if (n % 5, n % 3):
8788
// Or specify each branch separately
8889
if:
8990
user.email:
90-
send_confirmation_email(user.email)
91-
user.phone or user.messenger_id:
92-
send_confirmation_text(user)
91+
send confirmation email(user.email)
92+
user.phone OR user.messenger_id:
93+
send confirmation text(user)
9394
```
9495

9596
Array operators and functional constructs replace the need for most loops, but Informal still comes with a flexible for loop to process any kind of data.
@@ -110,19 +111,19 @@ months: {"January": 1, "February": 2, "March": 3, "April": 4,
110111
"May": 5, "June": 6, "July": 7, "August": 8,
111112
"September": 9, "October": 10, "November": 11, "December": 12}
112113
113-
invert_months = for month_str, month_num in months:
114-
{ month_num : month_str }
114+
invert months = for month str, month num IN months:
115+
{ month num : month str }
115116
116117
// You can iterate over multiple data streams at once.
117118
// This often comes in useful for "zipping" values together.
118119
brr = [10, 20, 30, 40, 50]
119-
for x in arr, y in brr:
120+
for x IN arr, y IN brr:
120121
x + y
121122
122123
// [11, 22, 33, 44, 55]
123124
124125
// You can specify guard clauses to break out of loops early.
125-
for x in [1..10] if x < 4:
126+
for x IN [1..10]: if x < 4
126127
x + 10
127128
128129
// Or leave out the conditional clause, to loop "while" the guard-clause is true.
@@ -206,13 +207,9 @@ d.year == "2023"
206207
d2 = DateString(year="2023", month="03", day="05")
207208
d == d2
208209
209-
// Functional primitives.
210-
// Use "each" to map over each element of an array.
211-
double_array = double(each array)
212-
213210
214211
// Anonymous functions
215-
x: x + 1
212+
(x): x + 1
216213
// You can avoid naming x in these cases.
217214
array.map(_ + 1)
218215

0 commit comments

Comments
 (0)