Skip to content

class C(x: R) not the same as class C(private val x: R) #2

@aryairani

Description

@aryairani
scala> class C(private val x: Int) { def add(c: C) = x + c.x }
defined class C
scala> class C(x: Int) { def add(c: C) = x + c.x }
 error: type mismatch;
 found   : c.type (with underlying type C)
 required: ?{val x: ?}

I agree they are similar in other cases though. :-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions