Hacker News new | ask | show | jobs
by AndresNavarro 1871 days ago
What I took from the article is that it's useful when combined with type inference. So in Zig you could do:

  var x : u8 = 5;
  var y = @as(u32, x);
OR

  var x : u8 = 5;
  var y : u32 = x;
The cast is needed in the first case to force the inference y: u32, otherwise it would be y: u8