• Willem@kutsuya.dev
    link
    fedilink
    arrow-up
    8
    arrow-down
    1
    ·
    1 day ago

    On that last note, can’t you use the explicit interface implementation in C#?

    e.g.

    public class SampleClass : IControl, ISurface
    {
        void IControl.Paint()
        {
            System.Console.WriteLine("IControl.Paint");
        }
        void ISurface.Paint()
        {
            System.Console.WriteLine("ISurface.Paint");
        }
    }
    
    • pivot_root@lemmy.world
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      edit-2
      24 hours ago

      Edit: I misread your comment as “like in C#” and wrote this as an answer to the non-existent question of “can’t you use explicit interfaces like in C#”

      I haven’t kept up with recent Java developments, but with Go, you’re out of luck. Interface implementations are completely implicit. You don’t even have an implements keyword.

      Edit: For Java, a cursory search suggests that they haven’t yet added explicit interfaces: https://stackoverflow.com/questions/19111090/does-java-support-explicit-interface-implementation-like-c

      • ඞmir@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        1 day ago

        He mentioned C#, which does let you explicitly choose to implement same-name functions of two interfaces with different code

        • pivot_root@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          24 hours ago

          For some reason, my brain inserted a “like” before “in C#”, and answered the question of “can’t you use explicit interfaces like in C#.”