@OsrsNeedsF2P
link
fedilink
18 месяцев

Can you give examples? From the description, it seems like most languages (like Java) can store data in enums?

@acabjones@lemmygrad.ml
link
fedilink
48 месяцев

I think they mean that enum variants can contain fields, i.e. individual variants are themselves structs or tuple structs. AFAIK the closest thing to this in a C-like lang would be a tagged union type.

@lemtoman
creator
link
fedilink
38 месяцев

oh yes thats what i mean. Coded in rust, loved this feature, went back to python a bit and became sad that I couldnt do the same. Feels stupid that a variable can be different types depending on the situation, and having a dataclass where just one field is relevant seems too dumb

Rust Programming
!rust
Create a post
  • 0 users online
  • 1 user / day
  • 7 users / week
  • 10 users / month
  • 47 users / 6 months
  • 2.1K subscribers
  • 392 Posts
  • 438 Comments
  • Modlog