Skip to content

Instantly share code, notes, and snippets.

@mandel59
Created January 25, 2012 13:38
Show Gist options
  • Save mandel59/1676290 to your computer and use it in GitHub Desktop.
Save mandel59/1676290 to your computer and use it in GitHub Desktop.
Shared box and unique box
use std;
import std::io::println;
fn main() {
// shared box
let i = @mutable 10;
println(int::str(*i)); // => 10
let j = i;
*j = 20;
println(int::str(*i)); // => 20
// unique box
let i = ~mutable 10;
println(int::str(*i)); // => 10
let j = i;
*j = 20;
println(int::str(*i)); // => 10
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment