Skip to content

Commit

Permalink
Update migrate-v4.md
Browse files Browse the repository at this point in the history
  • Loading branch information
matcool authored Nov 13, 2024
1 parent 770e02c commit d83d62b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tutorials/migrate-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
* Snake case methods renamed to camel case
* Universal `GEODE_UNWRAP(res)` and `GEODE_UNWRAP_INTO(value, res)` macros
* These macros were already previously available, but this is just a reminder that they can help a lot when dealing with results.
```cpp
Result<std::string> addValues(matjson::Value json) {
// Value::asInt() returns a Result<int>
GEODE_UNWRAP_INTO(int a, json["a"].asInt());
GEODE_UNWRAP_INTO(int b, json["b"].asInt());
// must wrap return value with Ok
return Ok(fmt::format("sum is {}", a + b));
}
```
* If you only ever expect to build your code with **clang**, you can use the `GEODE_UNWRAP` macro like so, for convenience:
```cpp
Result<int> getInt();
Expand Down

0 comments on commit d83d62b

Please sign in to comment.