So will we always have to dereference a ref variable using the asterisk symbol? In effect this is passing a pointer (like C), correct? What about if we want to call a method on a ref variable, will it be a.foo(), or (*a).foo()?
Thanks -- Ziad On Wed, Oct 3, 2012 at 7:15 PM, Patrick Walton <[email protected]> wrote: > On 10/3/12 7:13 PM, Amitava Shee wrote: > >> I just built rust from git source on my osx 10.6.8. >> >> amitava$ rustc --version >> rustc 0.4 (c3f9b72 2012-09-30 21:35:32 -0700) >> host: x86_64-apple-darwin >> >> I am trying to compile the following "hello.rs <http://hello.rs>" >> >> >> fn main() { >> let x = ["hello","world"]; >> for x.each |y| { >> io::println(y); >> } >> } >> >> I get the following error >> amitava:l2 amitava$ make >> rustc -g hello.rs <http://hello.rs> >> >> hello.rs:4:16: 4:17 error: mismatched types: expected `&/str` but found >> `&&static/str` (expected &/str but found &-ptr) >> hello.rs:4 <http://hello.rs:4> io::println(y); >> >> ^ >> error: aborting due to previous error >> make: *** [hello] Error 101 >> >> What am I missing? >> > > each now returns a reference, so you want `io::println(*y)`. > > Patrick > > > ______________________________**_________________ > Rust-dev mailing list > [email protected] > https://mail.mozilla.org/**listinfo/rust-dev<https://mail.mozilla.org/listinfo/rust-dev> >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
