[vala-tests] examples/value.vala: updated from wiki
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala-tests] examples/value.vala: updated from wiki
- Date: Wed, 7 Apr 2010 22:18:46 +0000 (UTC)
commit e91be6d0f7225d8070c94cb427583ecee49bdd8d
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Thu Apr 1 20:39:24 2010 +0200
examples/value.vala: updated from wiki
tests/examples/value.vala | 21 +++++++--------------
1 files changed, 7 insertions(+), 14 deletions(-)
---
diff --git a/tests/examples/value.vala b/tests/examples/value.vala
index 77e2eff..34704e5 100644
--- a/tests/examples/value.vala
+++ b/tests/examples/value.vala
@@ -2,22 +2,15 @@
// http://live.gnome.org/Vala/ValueSample vala-test:examples/value.vala
void main () {
- // initialize a GLib.Value of type int (G_TYPE_INT)
- Value prop_val = Value (typeof (int));
+ Value v; // a GLib.Value
- // set a value
- prop_val.set_int (5);
- print ("value: %d\n", prop_val.get_int ());
+ v = 5; // an integer auto-boxed into a Value
+ print ("value: %d\n", (int) v); // unboxing via cast
// reset to its default value
- prop_val.reset ();
- print ("value: %d\n", prop_val.get_int ());
+ v.reset ();
+ print ("value: %d\n", (int) v); // unboxing via cast
- // unset the value
- prop_val.unset ();
-
- // init with type string
- prop_val.init (typeof (string));
- prop_val.set_string ("string");
- print ("value: %s\n", prop_val.get_string ());
+ v = "hello"; // a string auto-boxed into a Value
+ print ("value: %s\n", (string) v); // unboxing via cast
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]