What is the difference between fn(inout v: T) and fn(ref v: T) ?

Both work the same if the Origin is inferred for ref? What are the differences?
3 Replies
Darkmatter
Darkmatter4d ago
fn foo(ref v: T) is generic over mutability. You can use __origin_of(v).is_mutable to check that.
Samuel Ibarra
Samuel IbarraOP3d ago
So, when I use inout, the variable should be mutable. Otherwise, I'll get compiler error I guess. But ref can use both mutable and immutable. Is my statement correct?
Darkmatter
Darkmatter3d ago
Yes
Want results from more Discord servers?
Add your server