diff options
author | George Marques <george@gmarqu.es> | 2016-11-22 08:08:59 -0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-22 08:08:59 -0200 |
commit | a692b7a1c1c2f2e836d5c235d1b55288535dca84 (patch) | |
tree | 112f69fecacc1112d9c6d6dfc0a126ac4bf1167e /core/array.cpp | |
parent | 830ab4ea8da61708deb681034e66a70f847dadf1 (diff) | |
parent | bf4fda64fd403d589278919cff01c3207164207e (diff) |
Merge pull request #7149 from Kazuo256/array-last
Add Array.front() and Array.back()
Diffstat (limited to 'core/array.cpp')
-rw-r--r-- | core/array.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/array.cpp b/core/array.cpp index 683a43e3d0..f7ca67b6a3 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -150,6 +150,16 @@ void Array::erase(const Variant& p_value) { _p->array.erase(p_value); } +Variant Array::front() const { + ERR_FAIL_COND_V(_p->array.size() == 0, Variant()); + return operator[](0); +} + +Variant Array::back() const { + ERR_FAIL_COND_V(_p->array.size() == 0, Variant()); + return operator[](_p->array.size() - 1); +} + int Array::find(const Variant& p_value, int p_from) const { return _p->array.find(p_value, p_from); |