Esempio n. 1
0
        public static object Shift(RubyContext /*!*/ context, Hash /*!*/ self)
        {
            RubyUtils.RequiresNotFrozen(context, self);

            if (self.Count == 0)
            {
                return(_DefaultSite.Target(_DefaultSite, context, self, null));
            }

            IEnumerator <KeyValuePair <object, object> > e = self.GetEnumerator();

            e.MoveNext();
            KeyValuePair <object, object> pair = e.Current;

            self.Remove(pair.Key);

            return(IDictionaryOps.MakeArray(pair));
        }
Esempio n. 2
0
        public static object Shift(CallSiteStorage <Func <CallSite, Hash, object, object> > /*!*/ storage, Hash /*!*/ self)
        {
            self.RequireNotFrozen();

            if (self.Count == 0)
            {
                var site = storage.GetCallSite("default", 1);
                return(site.Target(site, self, null));
            }

            IEnumerator <KeyValuePair <object, object> > e = self.GetEnumerator();

            e.MoveNext();
            KeyValuePair <object, object> pair = e.Current;

            self.Remove(pair.Key);

            return(IDictionaryOps.MakeArray(pair));
        }