From 37762a92af58477d77a362c90adb7c6c3ee49413 Mon Sep 17 00:00:00 2001 From: Andreas Bichinger Date: Mon, 20 Nov 2023 17:36:45 +0100 Subject: [PATCH] Update README --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e5716d..3b16ab2 100644 --- a/README.md +++ b/README.md @@ -162,13 +162,13 @@ Fields are accessed in a similar way. Assuming `foo` has a field called "Length" "foo.Length > 9000" -Accessors can be nested to any depth, like the following +The values of a `map` are accessed in the same way. Assuming the parameter `foo` is `map[string]int{ "bar": 1 }` - "foo.Bar.Baz.SomeFunction()" + "foo.bar == 1" -However it is not _currently_ supported to access values in `map`s. So the following will not work +Accessors can be nested to any depth, like the following - "foo.SomeMap['key']" + "foo.Bar.Baz.SomeFunction()" This may be convenient, but note that using accessors involves a _lot_ of reflection. This makes the expression about four times slower than just using a parameter (consult the benchmarks for more precise measurements on your system). If at all reasonable, the author recommends extracting the values you care about into a parameter map beforehand, or defining a struct that implements the `Parameters` interface, and which grabs fields as required. If there are functions you want to use, it's better to pass them as expression functions (see the above section). These approaches use no reflection, and are designed to be fast and clean.