Call an object method: Difference between revisions

→‎{{header|Rust}}: Added info about references to objects.
(→‎{{header|Rust}}: Added info about references to objects.)
Line 1,212:
// by calling the instance method of object foo
println!("The answer to life is {}.", foo.get_the_answer_to_life());
// Note that in Rust, methods still work on references to the object.
// Rust will automatically do the appropriate dereferencing to get the method to work:
let lots_of_references = &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&foo;
println!("The answer to life is still {}." lots_of_references.get_the_answer_to_life());
}</lang>