This page is no longer maintained — Please continue to the home page at www.scala-lang.org

overloaded local function

2 replies
HjP
Joined: 2012-02-07,
User offline. Last seen 32 weeks 2 days ago.

Hi,

why does the following declaration of the overloaded local function
"inner" lead to the error "method is defined twice":

def outer() {
def inner():Int = 1
def inner(x: Int):Int = x
}

Thanks,
HjP

Jason Zaugg
Joined: 2009-05-18,
User offline. Last seen 38 weeks 5 days ago.
Re: overloaded local function
On Tue, Feb 7, 2012 at 3:35 AM, HjP <Hjalmar [dot] Peters [at] gmx [dot] de> wrote:
Hi,

why does the following declaration of the overloaded local function
"inner" lead to the error "method is defined twice":

def outer() {
       def inner():Int = 1
       def inner(x: Int):Int = x
}

The language does not allow overloading of local methods. Choose different names for them.
-jason
Naftoli Gugenheim
Joined: 2008-12-17,
User offline. Last seen 42 years 45 weeks ago.
overloaded local function
What's the reason?

On Tuesday, February 7, 2012, Jason Zaugg wrote:
On Tue, Feb 7, 2012 at 3:35 AM, HjP <Hjalmar [dot] Peters [at] gmx [dot] de> wrote:
Hi,

why does the following declaration of the overloaded local function
"inner" lead to the error "method is defined twice":

def outer() {
       def inner():Int = 1
       def inner(x: Int):Int = x
}

The language does not allow overloading of local methods. Choose different names for them.
-jason

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland