• whiwake@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 days ago

    This might confuse a lot of people

    class Unicorn {
      prance() {
        System.print("The unicorn prances in a fancy manner!")
      }
    
      prance(where) {
        System.print("The unicorn prances in %(where).")
      }
    
      prance(where, when) {
        System.print("The unicorn prances in %(where) at %(when).")
      }
    }
    
    • xxce2AAb@feddit.dk
      link
      fedilink
      English
      arrow-up
      3
      ·
      4 days ago

      It’s not obvious to me what you mean, exactly. What do you find confusing about it?

      • whiwake@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        2
        ·
        edit-2
        4 days ago

        I’m saying that when the project gets big, and each of those methods get long, A developer who is new to the project might have some confusion as to why there are methods with the same exact name inside of a class.