Just another update

This commit is contained in:
Ingy döt Net 2015-02-20 00:35:01 -05:00
parent a25938f123
commit 00a190b0a6
6591 changed files with 94363 additions and 23227 deletions

View file

@ -0,0 +1,5 @@
(Long/toHexString 15) ; use forward slash for static methods
(System/currentTimeMillis)
(.equals 1 2) ; use dot operator to call instance methods
(. 1 (equals 2)) ; alternative style

View file

@ -0,0 +1,2 @@
# Static
Method( obj, other, arg );

View file

@ -0,0 +1,2 @@
# Instance
Method( obj, other, arg );

View file

@ -0,0 +1,26 @@
struct Foo;
impl Foo {
// implementation of an instance method for struct Foo
// returning the answer to life
fn get_the_answer_to_life(&self) -> i32 {
42
}
// implementation of a static method for struct Foo
// returning a new instance object
fn new() -> Foo {
println!("Hello, world!");
Foo // returning the new Foo object
}
}
fn main() {
// create the instance object foo,
// by calling the static method new of struct Foo
let foo = Foo::new();
// get the answer to life
// by calling the instance method of object foo
println!("The answer to life is {}.", foo.get_the_answer_to_life());
}