Пример #1
0
 /// <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)
                       );
         }
     }
Пример #2
0
 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}";
 }