two type parameters with the same name

前端 未结 4 780
野趣味
野趣味 2021-01-02 23:44

I am wondering why the two type parameters (named \"A\") with the same name (\"A\") is allowed as per the example below. I know this is a POOR naming of type parameters, do

4条回答
  •  萌比男神i
    2021-01-03 00:10

    Its not just related to scala. In most languages you can do that. Because as you said the variables are in different scope.

    In c#

    class test
    {
          int i;
          void method(int i)
          {
              this.i = i;
          }
    }
    

    this represents the self type. I am not sure about the this functionality in scala. But the reason for your question is scope level.

提交回复
热议问题