Adds Unary length operator
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Upsilon.BaseTypes.Number;
|
||||
using Upsilon.BaseTypes.ScriptTypeInterfaces;
|
||||
using Upsilon.Evaluator;
|
||||
using Upsilon.Text;
|
||||
|
||||
namespace Upsilon.BaseTypes.UserData
|
||||
{
|
||||
internal class DictionaryUserData : ScriptType, IUserData
|
||||
internal class DictionaryUserData : ScriptType, IUserData, ILengthType
|
||||
{
|
||||
public IDictionary Dictionary { get; }
|
||||
|
||||
@@ -47,5 +50,10 @@ namespace Upsilon.BaseTypes.UserData
|
||||
{
|
||||
return Dictionary.GetType();
|
||||
}
|
||||
|
||||
public ScriptNumberLong Length()
|
||||
{
|
||||
return new ScriptNumberLong(Dictionary.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using Upsilon.Text;
|
||||
|
||||
namespace Upsilon.BaseTypes.UserData
|
||||
{
|
||||
internal class ListUserData : ScriptType, IUserData, IIterable
|
||||
internal class ListUserData : ScriptType, IUserData, IIterable, ILengthType
|
||||
{
|
||||
private IList List { get; }
|
||||
|
||||
@@ -66,5 +66,10 @@ namespace Upsilon.BaseTypes.UserData
|
||||
yield return new ScriptNumberLong(i);
|
||||
}
|
||||
}
|
||||
|
||||
public ScriptNumberLong Length()
|
||||
{
|
||||
return new ScriptNumberLong(List.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user