Skip to content

Bug in example code of "Scala 3: Scala for Python Developers" #2113

Closed
@gverbruggen

Description

@gverbruggen

Near the bottom of the document there's this example:

Filtering:

# Python
f = lambda x: x if x > 1 else 1 
x = filter(f, numbers)
// Scala
val x = numbers.filter(_ > 1)

That first line of Python is wrong.

The correct python for the filter is:

f = lambda x: x > 1
x = filter(f, numbers)

And if you want to more closely mirror the Scala example:

x = tuple(filter(lambda x: x > 1, numbers))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions