Re: [Vala] Replacing "void method ( out Type)" with "Type method()"



Adi Roiban wrote:
But when doing the same trick to GLib.Time i got

                public Time.gm.now () {
                    Time.gm(time_t());
                }

                public Time.local.now () {
                    Time.local(time_t());
                }

glib-2.0.vapi:1857.3-1857.20: error: missing return type in method
`Time.gm´
              public Time.gm.now () {
              ^^^^^^^^^^^^^^^^^^
glib-2.0.vapi:1861.3-1861.23: error: missing return type in method
`Time.local´
              public Time.local.now () {


I don't know exactly how the VAPI code fits , how to use a contstructor,
do I have access to "this" ...
 
Many thanks!

I'd do this in 'struct Time':

  public static Time gm_now () {
      return Time.gm (time_t ());
  }

  public static Time local_now () {
      return Time.local (time_t ());
  }

Usage:

  Time time = Time.gm_now ();
  stdout.printf ("%s\n", time.to_string ());


Regards,

Frederik



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]