Created
January 25, 2012 13:38
-
-
Save mandel59/1676290 to your computer and use it in GitHub Desktop.
Shared box and unique box
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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