/// <summary> /// Safely set the value of an indexed variable with an index /// </summary> /// <remark> /// source should refer to the index' source /// </remark> public static void SetIndex( Source source, Shell.Types.IShellIndexable indexable, Shell.Types.IShellData index, Shell.Types.IShellData value ) { if (indexable is Shell.Types.Array) { if (index is Shell.Types.Number num && num.isInt) { indexable.Replace(index, value); } else { throw new Shell.Problems.UnexpectedType( source, index, typeof(Shell.Types.Number) ); } }
public IndexOutOfRange(Source src, Shell.Types.IShellData index, Shell.Types.IShellIndexable obj) { Message = $"Expected an index from \n{new Shell.Types.Array(obj.ListIndices())}\n at {src}, got {index}"; }
public void Set(string name, Shell.Types.IShellData value) => state.CurrentVariables().Set(name, value);