-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
13 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
# Introduction | ||
|
||
Printing in Cairo allows you to display messages, debug information, or formatted values during program execution. | ||
With versatile macros like println! and format!, you can output basic data types, custom formats, or even complex structures. | ||
This makes it easy to inspect and communicate program behavior effectively. | ||
With versatile macros like println! | ||
and format!, you can output basic data types, custom formats, or even complex structures. | ||
This makes it easy to inspect and communicate program behavior effectively. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
### Hints | ||
# Hints | ||
|
||
#### General | ||
# General | ||
|
||
- [The Cairo Book: ByteArrays][book-bytearrays] | ||
- [Starknet By Example: Strings & ByteArrays][sbe-strings] | ||
|
||
#### 1. Format a magical chant | ||
### 1. Format a magical chant | ||
|
||
- Use the `format!` macro to combine multiple `ByteArray` inputs into a single string. | ||
- Separate the chants with a delimiter such as `"-"` to match the expected output. | ||
- Ensure the output is returned as a `ByteArray`. | ||
|
||
#### 2. Implement a `Display` trait for `EchoStone` | ||
### 2. Implement a `Display` trait for `EchoStone` | ||
|
||
- The `Display` trait allows you to define how the `EchoStone` should appear when printed with `{}`. | ||
- Use the `write!` macro within the `fmt` function to format the output string. | ||
- Include both `power` and `duration` fields in a clear and concise format, e.g., `EchoStone [power: X, duration: Y]`. | ||
|
||
#### 3. Implement a `Debug` trait for `EchoStone` | ||
### 3. Implement a `Debug` trait for `EchoStone` | ||
|
||
- The `Debug` trait is used for debugging purposes, allowing for more detailed or structured output when printed with `{:?}`. | ||
- Follow a clear debugging format, such as `Debugging EchoStone: { power: X, duration: Y }`. | ||
- Use the `write!` macro to create the debug output. | ||
|
||
[book-bytearrays]: https://book.cairo-lang.org/ch02-02-data-types.html#string-types | ||
[sbe-strings]: https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings | ||
[sbe-strings]: https://starknet-by-example.voyager.online/getting-started/basics/bytearrays-strings |