Skip to content

Can lambda expressions only be used as conditional judgments and return bool? #292

@airs1991

Description

@airs1991

To implement the mocked foreach, I use an extension method:

public static class Extend
{
     public static void All<T>(this IEnumerable<T> source, Action<T> action)
     {
         foreach (var item in source)
             action(item);
     }
}

I want to change the money field of each npc in List<Npc> NearNpcs to 10, so I wrote a Lambda string:

"NearNpcs.All(n=>n.money=10)"

(The InterpreterOptions.LambdaExpressions setting is already turned on, and the Extend class and associated required variables are registered.)

It reported the error:

DynamicExpresso.Exceptions.ParseException: A value of type 'Int32' cannot be converted to type 'Boolean' (at index 0).

Does Lambda parsing currently only support conditional parsing that can return bool?

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