-
-
Notifications
You must be signed in to change notification settings - Fork 463
-
In my code,i want to use any check slice data,but my slice is about []string,i don't kown how to get element about slice in my expression.
In your example:
type Tweet struct {
Len int
}
type Env struct {
Tweets []Tweet
}
func main() {
code := all(Tweets, {.Len <= 240})
program, err := expr.Compile(code, expr.Env(Env{}))
if err != nil {
panic(err)
}
env := Env{
Tweets: []Tweet{{42}, {98}, {69}},
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}
In my example:
type Env struct {
Tweets []int
}
func main() {
code := all(Tweets, {.<= 240})
program, err := expr.Compile(code, expr.Env(Env{}))
if err != nil {
panic(err)
}
env := Env{
Tweets: []int{42, 98, 69},
}
output, err := expr.Run(program, env)
if err != nil {
panic(err)
}
fmt.Println(output)
}
the code compile error:Error compiling expression: expected name
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
antonmedv
Nov 30, 2023
Use #
Replies: 1 comment
-
Use #
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Answer selected by
antonmedv
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment