Skip to content

usefulness of the nameof pattern is not clear #36396

@daveyostcom

Description

@daveyostcom

A compelling use for the nameof pattern is not presented. I can’t see the usefulness from the example given.

let f (str: string) =
    match str with
    | nameof str -> "It's 'str'!"
    | _ -> "It is not 'str'!"

seems to work identically to this:

let f2 (s: string) =
    match s with
    | "str" -> "It's 'str'!"
    | _ -> "It is not 'str'!"

The page linked does not help to clarify.


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions