[vala/wip/attributes: 6/39] Specify default values in Attribute methods
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes: 6/39] Specify default values in Attribute methods
- Date: Mon, 1 Aug 2011 13:39:17 +0000 (UTC)
commit ffb78602b7c4cd40a4ba4e06eaeb8fcc66a22775
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]