≈ the.bay.news

Why is assignment of a struct allowed and comparison not

Ziggit
Why is assignment of a struct allowed and comparison not
Well… the title of this topic is already self-explanatory. Why can’t we (always) compare structs while assigning is always allowed? const b: AnyStruct = .init(...); const a: AnyStruct = b; // always allowed. const eql: bool = (a == b); // not always allowed. error: operator == not allowed for type I know this is because the internal layout of a struct. But in my mind it goes like: “if Zig can copy it should also be able to compare”.

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.