Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slices #251

Open
ivanstepanovftw opened this issue Jul 6, 2024 · 0 comments
Open

Slices #251

ivanstepanovftw opened this issue Jul 6, 2024 · 0 comments

Comments

@ivanstepanovftw
Copy link

website/versioned_docs/version-0.12/01-language-basics/14-slices.mdx

Who stumbled with reinterpreting comptime_int to a slice [32]u8, you need first to define comptime_int as integer u256 then convert it into a slice using @bitCast.

const key: u256 = 0x1;
const key_arr: [32]u8 = @bitCast(key);

I think this example would teach why comptime_int should be defined as sized integer, and how to do something like C++ have - reinterpret_cast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant