Skip to content

Commit 5e75ede

Browse files
committed
Simplified HasData()
1 parent 80e64cf commit 5e75ede

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

QueryArray.nut

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,18 +130,14 @@ class csQuery.QueryArray {
130130
}
131131

132132
function HasData(key) {
133-
local hasData = false;
134133
local ent = this.Get(0);
135134
ent.ValidateScriptScope();
136135
local scope = ent.GetScriptScope();
137136

138-
if (!("customData" in scope))
139-
return;
140-
141-
if (key in scope.customData)
142-
hasData = true;
137+
if ("customData" in scope && key in scope.customData)
138+
return true;
143139

144-
return hasData;
140+
return false;
145141
}
146142

147143
function GetData(key = null) {

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ QueryArray Off(string output, string id);
6060

6161
// Saves the given value with the given identification (key) in the first entity's scope. IMPORTANT: Data saved will 'live' throughout all rounds.
6262
QueryArray SaveData(string key, object value);
63-
// Returns whether data under the given key has already been stored in the first entity's scope. Will not throw an exception if SaveData() has never been used before.
63+
// Returns whether data under the given key has already been stored in the first entity's scope.
6464
bool HasData(string key);
6565
// Returns an array of objects which match with the given key in the first entity's scoep. Will throw an exception if SaveData() has not been used with the first entity.
6666
object[] GetData(string key);

0 commit comments

Comments
 (0)