Code Review: ExplicitIfaces

tfpt review “/shelveset:ExplicitIfaces;REDMOND\tomat”
Comment :
Generalizes clr_member to support calls to an explicit implementation
of an interface method as well as a base class method hidden by a “new
slot” method.

  1. interfaces

public interface I {
int Foo();
}

public interface J {
int Foo();
}

class C : I, J {
int I.Foo() { return 1; }
int J.Foo() { return 2; }
}

C.new.foo # => undefined method `foo’
C.new.clr_member(I, :foo).call # => 1
C.new.clr_member(J, :foo).call # => 2

  1. new slot methods

    public class B {
        public int Foo() {
            return 1;
        }
    }
    
    public class C : B {
        public new int Foo() {
            return 2;
        }
    }
    

c = C.new
p c.foo # => 2
p c.clr_member(B, :foo).call # => 1

Tomas

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs