Skip to content

Update solutions for type inference exercises in the compendium #769

@johannesnydahl

Description

@johannesnydahl

There seems to be some solutions to type inference exercises that are incorrect in the current version of the compendium, presumably due to more precise type inference in newer Scala compiler versions for union types.

I recall finding a few of these errors in the past, but this is the only one I have noted down (Exercise 2C, W08):

image

The solution says:

image

However, when trying this myself using Scala REPL the compiler infer more precise types than Any and AnyVal:
image

I personally think that solutions to exercises like these have to be revised in order to not confuse students. Maybe we can include both the general and the precise type?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions