Skip to content
This repository was archived by the owner on Jun 5, 2023. It is now read-only.

allow any method with proper signature to be used as an extractor #218

@erikerlandson

Description

@erikerlandson

This feature request stems from this discussion: scala/scala3#12793
At least 3 alternatives were mentioned on that discussion thread. The one I believe is most promising is to allow any function or method having an appropriate signature to be used as an extractor.

def asInt(s: String): Option[Int] = s.toIntOption

val x: Int = "4" match
    case asInt(v) => v
    case _ => 0

So any methods with valid extractor type signatures

A => Option[B]
A => Boolean
A => Option[(B, C, ...)]
// etc

can be used in an extractor matching context

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