Vala examples II

Today, we learn the basic vala types, very similar to C types .


/* types.vala                          */
/* valac -o types types.vala      */

using GLib;

public class Sample : Object {

        public int integer1 = 1 ;
        public char character1 = 'a' ;
        public long long1 = 1 ;
        public double double1 = 0.1 ;
        public string string1 = "Hello !!" ;

        public Sample () {
        }

        public void show_class_variables () {
                stdout.printf ("integer1 value => %i\n", integer1);
                stdout.printf ("char1 value => %c\n", character1);
                stdout.printf ("long1 value => %i\n", long1);
                stdout.printf ("double1 value => %e\n", double1);
                stdout.printf ("string1 value => %s\n", string1);

        }

        static int main (string[] args) {
                var sample = new Sample ();
                sample.show_class_variables();
                return 0;
        }
}

Leave a Reply

Your email address will not be published. Required fields are marked *