arity() public method

public arity ( ) : int
return int
Beispiel #1
0
        /**
         * Determine if two tuples are equal. Tuples are equal if they have the same
         * arity and all of the elements are equal.
         *
         * @param o
         *                the tuple to compare to.
         *
         * @return true if the tuples have the same arity and all the elements are
         *         equal.
         */
        public override bool Equals(Object o)
        {
            if (!(o is OtpErlangTuple))
            {
                return(false);
            }

            OtpErlangTuple t = (OtpErlangTuple)o;
            int            a = arity();

            if (a != t.arity())
            {
                return(false);
            }

            for (int i = 0; i < a; i++)
            {
                if (!elems[i].Equals(t.elems[i]))
                {
                    return(false); // early exit
                }
            }

            return(true);
        }
Beispiel #2
0
        /**
         * Receive an RPC reply from the remote Erlang node. This convenience
         * function receives a message from the remote node, and expects it to have
         * the following format:
         *
         * <pre>
         * { rex, Term }
         * </pre>
         *
         * @return the second element of the tuple if the received message is a
         *         two-tuple, otherwise null. No further error checking is
         *         performed.
         *
         * @exception java.io.IOException
         *                    if the connection is not active or a communication
         *                    error occurs.
         *
         * @exception OtpErlangExit
         *                    if an exit signal is received from a process on the
         *                    peer node.
         *
         * @exception OtpAuthException
         *                    if the remote node sends a message containing an
         *                    invalid cookie.
         */
        public OtpErlangObject receiveRPC()
        {
            OtpErlangObject msg = receive();

            if (msg is OtpErlangTuple)
            {
                OtpErlangTuple t = (OtpErlangTuple)msg;
                if (t.arity() == 2)
                {
                    return(t.elementAt(1)); // obs: second element
                }
            }

            return(null);
        }