[rust-dev] class.new

Mic mictadlo at gmail.com
Wed Apr 11 06:13:34 PDT 2012


Thank you. I did a mistake I meant cat.*new*(1, 2). It would be easier
to distinguish
between a function cat(1,2) and a class cat(1,2).

On Wed, Apr 11, 2012 at 10:11 PM, Amitava Shee <amitava.shee at gmail.com>wrote:

> 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/8a71b4de/attachment-0001.html>


More information about the Rust-dev mailing list