Parcourir la source

Make value nullable for Associative.remove

Billy Barrow il y a 1 semaine
Parent
commit
bc6c032877

+ 2 - 1
src/lib/DataStructures/Dictionary.vala

@@ -31,12 +31,13 @@ namespace Invercargill.DataStructures {
             hash_set.set(new KeyValuePair<TKey, TValue>(key, value));
         }
 
-        public bool remove (TKey key, out TValue? value) {
+        public bool remove (TKey key, out TValue? value = null) {
             var result = hash_set.remove (new KeyValuePair<TKey, TValue>(key, null));
             if(result != null) {
                 value = result.value;
                 return true;
             }
+            value = null;
             return false;
         }
 

+ 1 - 1
src/lib/Interfaces/Associative.vala

@@ -5,7 +5,7 @@ namespace Invercargill {
 
         public abstract void @set(TKey key, TValue value);
         public abstract bool add(TKey key, TValue value);
-        public abstract bool remove(TKey key, out TValue? value);
+        public abstract bool remove(TKey key, out TValue? value = null);
         public abstract void clear();
 
     }