AjErl.Language.Map.GetValue C# (CSharp) Method

GetValue() public method

public GetValue ( object key ) : object
key object
return object
        public object GetValue(object key)
        {
            int position = ((IList<object>)this.keys).IndexOf(key);

            if (position < 0)
                if (this.parent != null)
                    return this.parent.GetValue(key);
                else
                    throw new InvalidOperationException(string.Format("undefined key {0}", key));

            return this.values[position];
        }

Usage Example

Example #1
0
        public void CreateMap()
        {
            Map map = new Map(new object[] { new Atom("a"), new Atom("b") }, new object[] { 1, 2 });

            Assert.AreEqual(1, map.GetValue(new Atom("a")));
            Assert.AreEqual(2, map.GetValue(new Atom("b")));
        }
All Usage Examples Of AjErl.Language.Map::GetValue