Skip to content

Cannot get lambda code passed to a function using sourcecode.Args  #86

@lokifacio

Description

@lokifacio

Is there a way to get the source code of the lambda function passed to another function?

I get the expected result with basic types

def myBasicFunc(param: Int): String = {
 sourcecode.Args().head.head.toString
}

myBasicFunc(4) // Text(4,param)

But when I try to use the same approach with lambda functions I only get the generic function1 value

def myLambdaFunc(param: Int => Int): String = {
 sourcecode.Args().head.head.toString
}

myLambdaFunc(x => x*2) // Text(<function1>,param)

Is this the expected behavior? Am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions