Selaa lähdekoodia

Change Get to GetAtIndex

ApisNecros 1 vuosi sitten
vanhempi
säilyke
4569ccf491
1 muutettua tiedostoa jossa 5 lisäystä ja 8 poistoa
  1. 5 8
      IntComp/Stack.js

+ 5 - 8
IntComp/Stack.js

@@ -27,16 +27,13 @@ module.exports = class Stack {
     }
 
     /**
-     * Get a value from the stack
+     * Get a value at a given index on the stack
      *
-     * If an index isn't given, retrieves the value at the current
-     * location of the pointer
-     *
-     * @param {?number} index The index of the value to retrieve
-     * @returns {number} The value at the given index, or 0
+     * @param {number} index The index of the value to retrieve
+     * @returns {number} The value at the given index, or 0 if the index hasn't been defined yet
      */
-    Get(index = null) {
-        if (index !== null && (Number.isNaN(index) || !Number.isInteger(index))) {
+    GetAtIndex(index) {
+        if (index == null || Number.isNaN(index) || !Number.isInteger(index)) {
             throw new TypeError("index must be an integer");
         }