Returns the element at a specified index in a sequence.

@param positon The zero-base index of element which you want.
@param defaultValue The default value if the index is out of range.
@return The element at a specified index or default value
162459
function elementAt(index, defaultValue) {
  let i = 0;

  for (let item of this) {
    if (i === index) return item;
    i++;
  }

  return defaultValue;
}
643974
public <T> T get(String attr, Object defaultValue) {
		Object result = attrs.get(attr);
		return (T)(result != null ? result : defaultValue);
	}
1173781
protected String getPropertyDefaultValue(AnnotatedElement element) {
        if (element.isAnnotationPresent(DefaultValue.class)) {
            return element.getAnnotation(DefaultValue.class).value();
        }
        return null;
    }
457560
public float getFloat(String columnName, float defaultValue) {
        int index = getColumnIndex(columnName);
        if (isValidIndex(index)) {
            return getFloat(index);
        } else {
            return defaultValue;
        }
    }
126846
public String get(String key, String defaultValue) {
        String v = get(key);
        if (v==null)    v=defaultValue;
        return v;
    }
1090220
public static float getFloat(JsonObject object, String field, float defaultValue) {
        final JsonValue value = object.get(field);
        if (value == null || value.isNull()) {
            return defaultValue;
        } else {
            return value.asFloat();
        }
    }
975200
public int getInt(String key, int defaultValue) {
    if (containsKey(key)) {
      return Integer.parseInt(get(key));
    } else {
      return defaultValue;
    }
  }
1163869
private String getValueOrDefault(HttpServletRequest req, String paramName, String defaultValue) {
		final String value = req.getParameter(paramName);
		return StringUtils.isEmpty(value) ? defaultValue : value;
	}
382738
@CanIgnoreReturnValue // TODO(kak): Consider removing this?
  @Nullable
  public static <T> T getOnlyElement(Iterator<? extends T> iterator, @Nullable T defaultValue) {
    return iterator.hasNext() ? getOnlyElement(iterator) : defaultValue;
  }
820295
public void annotateDefaultValueLater(JCExpression defaultValue, Env<AttrContext> localEnv,
            MethodSymbol m, DiagnosticPosition deferPos)
    {
        normal(() -> {
            JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
            DiagnosticPosition prevLintPos = deferredLintHandler.setPos(deferPos);
            try {
                enterDefaultValue(defaultValue, localEnv, m);
            } finally {
                deferredLintHandler.setPos(prevLintPos);
                log.useSource(prev);
            }
        });

        validate(() -> { //validate annotations
            JavaFileObject prev = log.useSource(localEnv.toplevel.sourcefile);
            try {
                // if default value is an annotation, check it is a well-formed
                // annotation value (e.g. no duplicate values, no missing values, etc.)
                chk.validateAnnotationTree(defaultValue);
            } finally {
                log.useSource(prev);
            }
        });
    }
205934
public static String getAt(String list, char delimiter, int position, boolean ignoreEmpty, String defaultValue) {
	int len = list.length();
	if (len == 0) return defaultValue;
	int last = -1;
	int count = -1;

	for (int i = 0; i < len; i++) {
	    // char == delimiter
	    if (list.charAt(i) == delimiter) {
		if (ignoreEmpty && (last + 1) == i) {
		    last = i;
		    continue;
		}

		count++;
		if (count == position) {
		    return list.substring(last + 1, i);
		}
		last = i;
	    }
	}

	if (position == count + 1) {
	    if (!ignoreEmpty || last + 1 < len) return list.substring(last + 1);
	}
	return defaultValue;
    }
591538
public static <T> T getOrDefaultValue(String primaryKey, T defaultValue) {
        Object val = CFG.get(primaryKey);
        return val == null ? defaultValue : (T) CompatibleTypeUtils.convert(val, defaultValue.getClass());
    }
512908
public static Object get(Object o, int index, Object defaultValue) {
	if (index < 0) return null;
	if (o instanceof Object[]) {
	    Object[] arr = ((Object[]) o);
	    if (arr.length > index) return arr[index];
	}
	else if (o instanceof boolean[]) {
	    boolean[] arr = ((boolean[]) o);
	    if (arr.length > index) return arr[index] ? Boolean.TRUE : Boolean.FALSE;
	}
	else if (o instanceof byte[]) {
	    byte[] arr = ((byte[]) o);
	    if (arr.length > index) return new Byte(arr[index]);
	}
	else if (o instanceof char[]) {
	    char[] arr = ((char[]) o);
	    if (arr.length > index) return "" + (arr[index]);
	}
	else if (o instanceof short[]) {
	    short[] arr = ((short[]) o);
	    if (arr.length > index) return Short.valueOf(arr[index]);
	}
	else if (o instanceof int[]) {
	    int[] arr = ((int[]) o);
	    if (arr.length > index) return Integer.valueOf(arr[index]);
	}
	else if (o instanceof long[]) {
	    long[] arr = ((long[]) o);
	    if (arr.length > index) return Long.valueOf(arr[index]);
	}
	else if (o instanceof float[]) {
	    float[] arr = ((float[]) o);
	    if (arr.length > index) return new Float(arr[index]);
	}
	else if (o instanceof double[]) {
	    double[] arr = ((double[]) o);
	    if (arr.length > index) return new Double(arr[index]);
	}
	return defaultValue;
    }

    /**
     * sets a value to a array at defined index
     * 
     * @param o
     * @param index
     * @param value
     * @return value setted
     * @throws ArrayUtilException
     */
    public static Object set(Object o, int index, Object value) throws ArrayUtilException {
	if (index < 0) throw invalidIndex(index, 0);
	if (o instanceof Object[]) {
	    Object[] arr = ((Object[]) o);
	    if (arr.length > index) return arr[index] = value;
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof boolean[]) {
	    boolean[] arr = ((boolean[]) o);
	    if (arr.length > index) {
		arr[index] = Caster.toBooleanValue(value, false);
		return arr[index] ? Boolean.TRUE : Boolean.FALSE;
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof byte[]) {
	    byte[] arr = ((byte[]) o);
	    if (arr.length > index) {
		double v = Caster.toDoubleValue(value, true, Double.NaN);
		if (Decision.isValid(v)) {
		    return new Byte(arr[index] = (byte) v);
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof short[]) {
	    short[] arr = ((short[]) o);
	    if (arr.length > index) {
		double v = Caster.toDoubleValue(value, true, Double.NaN);
		if (Decision.isValid(v)) {
		    return Short.valueOf(arr[index] = (short) v);
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof int[]) {
	    int[] arr = ((int[]) o);
	    if (arr.length > index) {
		double v = Caster.toDoubleValue(value, true, Double.NaN);
		if (Decision.isValid(v)) {
		    return Integer.valueOf(arr[index] = (int) v);
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof long[]) {
	    long[] arr = ((long[]) o);
	    if (arr.length > index) {
		double v = Caster.toDoubleValue(value, true, Double.NaN);
		if (Decision.isValid(v)) {
		    return Long.valueOf(arr[index] = (long) v);
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof float[]) {
	    float[] arr = ((float[]) o);
	    if (arr.length > index) {
		double v = Caster.toDoubleValue(value, true, Double.NaN);
		if (Decision.isValid(v)) {
		    return new Float(arr[index] = (float) v);
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof double[]) {
	    double[] arr = ((double[]) o);
	    if (arr.length > index) {
		double v = Caster.toDoubleValue(value, true, Double.NaN);
		if (Decision.isValid(v)) {
		    return new Double(arr[index] = v);
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	else if (o instanceof char[]) {
	    char[] arr = ((char[]) o);
	    if (arr.length > index) {
		String str = Caster.toString(value, null);
		if (str != null && str.length() > 0) {
		    char c = str.charAt(0);
		    arr[index] = c;
		    return str;
		}
	    }
	    throw invalidIndex(index, arr.length);
	}
	throw new ArrayUtilException("Object [" + Caster.toClassName(o) + "] is not a Array");
    }
238962
public int toDialect(String ext, int defaultValue) {
	if (ext == null) return defaultValue;
	if (cfmlExtensions == null) _initExtensions();
	if (cfmlExtensions.contains(ext = ext.toLowerCase())) return CFMLEngine.DIALECT_CFML;
	if (luceeExtensions.contains(ext)) return CFMLEngine.DIALECT_LUCEE;
	return defaultValue;
    }
338633
public Collection<Object> getPropertyOrDefault(final String name, final Collection<Object> defaultValues) {
        if (this.properties.containsKey(name)) {
            return this.properties.get(name);
        }
        return defaultValues;
    }
121197
public Integer getIntegerProperty(String key, Integer defaultValue) {
        String val = getProperty(key, defaultValue.toString());
        try {
            Integer intVal = Integer.parseInt(val);
            return intVal;
        } catch (NumberFormatException e) {
            return defaultValue;
        }
    }
154727
public static Integer toIntObject(@Nullable String str, Integer defaultValue) {
		if (StringUtils.isEmpty(str)) {
			return defaultValue;
		}
		try {
			return Integer.valueOf(str);
		} catch (final NumberFormatException nfe) {
			return defaultValue;
		}
	}