[vala/wip/attributes: 6/36] Specify default values in Attribute methods
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 6/36] Specify default values in Attribute methods
- Date: Sun, 31 Jul 2011 17:20:38 +0000 (UTC)
commit 6058bf8f852a560dbbc91d4f33d0ad88165e56d0
Author: Luca Bruno <lucabru src gnome org>
Date: Wed Jul 6 09:52:40 2011 +0200
Specify default values in Attribute methods
vala/valaattribute.vala | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/vala/valaattribute.vala b/vala/valaattribute.vala
index 68d7539..63258e1 100644
--- a/vala/valaattribute.vala
+++ b/vala/valaattribute.vala
@@ -92,11 +92,11 @@ public class Vala.Attribute : CodeNode {
* @param name argument name
* @return integer value
*/
- public int get_integer (string name) {
+ public int get_integer (string name, int default_value = 0) {
string value = args.get (name);
if (value == null) {
- return 0;
+ return default_value;
}
return int.parse (value);
@@ -108,11 +108,11 @@ public class Vala.Attribute : CodeNode {
* @param name argument name
* @return double value
*/
- public double get_double (string name) {
+ public double get_double (string name, double default_value = 0) {
string value = args.get (name);
if (value == null) {
- return 0;
+ return default_value;
}
return double.parse (value);
@@ -124,7 +124,13 @@ public class Vala.Attribute : CodeNode {
* @param name argument name
* @return boolean value
*/
- public bool get_bool (string name) {
- return bool.parse (args.get (name));
+ public bool get_bool (string name, bool default_value = false) {
+ string value = args.get (name);
+
+ if (value == null) {
+ return default_value;
+ }
+
+ return bool.parse (value);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]