[vala/wip/attributes-clean: 1/21] Specify default values in Attribute methods
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/attributes-clean: 1/21] Specify default values in Attribute methods
- Date: Thu, 7 Jul 2011 13:56:55 +0000 (UTC)
commit 91712645cde6a2442129ca0c53eaf7ed7c8a8316
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]