summaryrefslogtreecommitdiff
path: root/core/array.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/array.cpp')
-rw-r--r--core/array.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/core/array.cpp b/core/array.cpp
index 65934d6ec9..a334af2c04 100644
--- a/core/array.cpp
+++ b/core/array.cpp
@@ -133,12 +133,18 @@ void Array::erase(const Variant &p_value) {
}
Variant Array::front() const {
- ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+ if (_p->array.size() == 0) {
+ ERR_EXPLAIN("Can't take value from empty array");
+ ERR_FAIL_V(Variant());
+ }
return operator[](0);
}
Variant Array::back() const {
- ERR_FAIL_COND_V(_p->array.size() == 0, Variant());
+ if (_p->array.size() == 0) {
+ ERR_EXPLAIN("Can't take value from empty array");
+ ERR_FAIL_V(Variant());
+ }
return operator[](_p->array.size() - 1);
}
@@ -165,8 +171,8 @@ int Array::rfind(const Variant &p_value, int p_from) const {
if (_p->array[i] == p_value) {
return i;
- };
- };
+ }
+ }
return -1;
}
@@ -186,8 +192,8 @@ int Array::count(const Variant &p_value) const {
if (_p->array[i] == p_value) {
amount++;
- };
- };
+ }
+ }
return amount;
}