You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a closure captures a field, it exposes the field as a mut T even if the original type was ref T. As a result you can mutate immutable references to fields using a closure:
class Thing {
let @values: Array[Int]
fn example {
fn { @values.pop } # This should error at compile-time, but it doesn't
}
}
The text was updated successfully, but these errors were encountered:
When a closure captures a field, it exposes the field as a
mut T
even if the original type wasref T
. As a result you can mutate immutable references to fields using a closure:The text was updated successfully, but these errors were encountered: