Remix.run Logo
kbolino 5 hours ago

I must disagree. Destructuring is nifty, but it is almost completely unrelated. The second value in any of the builtin two-value assignment forms is invariant on the type or size of RHS; it's always a boolean, and its meaning relates to the "kind" of RHS, not the exact type:

  msg, ok := <-ch    // ok means "channel ch is not closed"
  val, ok := m[key]  // ok means "map m contains key"
  dyn, ok := i.(T)   // ok means "interface i's dynamic type is T or implements T"
This new operation would be similar:

  arr, ok := [N]T(s) // ok means "slice s has len(s) == N"
For all of these cases, ok being true indicates that the other value is safe to use.