Skip to content

Commit 4cc21a5

Browse files
committed
strings and type todos
1 parent 6fe9309 commit 4cc21a5

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

content/posts/jai-guide.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ This is a table that hold a comparison of all fundamental types you should know
2727
| 64 bit integer signed | `s64` | ``long`` | ``long long`` | ``int64_t`` |
2828
| 64 bit integer unsigned | `u64` | ``ulong`` | ``unsigned long long`` | ``uint64_t`` |
2929
| boolean | `bool` | ``bool`` | ``bool`` | - |
30-
| character | `todo` | ``char`` | ``char`` | ``char16_t`` |
30+
| character | `u8` | ``char`` | ``char`` | ``char16_t`` |
3131
| string | `string` | ``string`` | ``string`` | - |
32-
| null | `todo` | ``null`` | ``nullptr`` | - |
32+
| null | `null` | ``null`` | ``nullptr`` | - |
3333

3434
Jai strings are array views over `u8` and are not null-terminated.
3535

@@ -91,7 +91,7 @@ for a: arr {
9191
}
9292
```
9393

94-
## Ternairy Operator
94+
## Ternary Operator
9595

9696

9797
## References
@@ -445,7 +445,18 @@ You can constrain polymorphic types with `/` and `interface` syntax.
445445

446446
## Strings
447447

448-
todo
448+
Jai strings are array views (slices) over `u8` and are not null-terminated. You can create string literals using double quotes:
449+
450+
```jai
451+
message: string = "Hello, World!";
452+
length: int = message.count; // get string length
453+
454+
// strings are just array views over u8
455+
data: *u8 = message.data; // get pointer to first byte
456+
457+
// you can slice strings
458+
substring: string = message[0..5]; // "Hello"
459+
```
449460

450461
Jai strings are are array views (slices) over `u8`, arrays are also not null terminated.
451462

0 commit comments

Comments
 (0)