[rust-dev] class.new

Amitava Shee amitava.shee at gmail.com
Wed Apr 11 05:11:43 PDT 2012


You don't need to invoke new -

let c : cat = cat(1, 2);

will do.

-Amitava

On Wed, Apr 11, 2012 at 5:54 AM, Mic <mictadlo at gmail.com> wrote:

> Hello,
> How about to create an instance with class.new like in Ruby, because in
> the class is a new method?
>
>      class  cat {
>          priv {
>              let mutable x : int;
>              fn meow() { log_err "Meow"; }
>          }
>
>          let y : int;
>
>          new(in_x : int, in_y : int) { x = in_x; self.y = in_y; }
>
>          fn speak() { meow(); }
>
>          fn eat() { ... }
>      }
>
>
>      let c : cat = cat(1, 2).*new*;
>      c.speak();
>
>
> _______________________________________________
> Rust-dev mailing list
> Rust-dev at mozilla.org
> https://mail.mozilla.org/listinfo/rust-dev
>
>


-- 
Amitava Shee
Software Architect

There are two ways of constructing a software design. One is to make it so
simple that there are obviously no deficiencies; the other is to make it so
complicated that there are no obvious deficiencies. The first method is far
more difficult.
-- C. A. R. Hoare The Emperor's Old Clothes, CACM February 1981
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20120411/69197353/attachment.html>


More information about the Rust-dev mailing list