[rust-dev] class.new

Mic mictadlo at gmail.com
Wed Apr 11 02:54:47 PDT 2012


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();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20120411/946c019c/attachment.html>


More information about the Rust-dev mailing list