kcl-lang / kcl-lang.io

KCL Website and Documentation Repo: https://kcl-lang.io
https://kcl-lang.github.io
Apache License 2.0
12 stars 33 forks source link

[FAQ] In a given schema, is there an easy way to extend an array default value? #345

Closed steeling closed 4 months ago

steeling commented 4 months ago

In a given schema, is there an easy way to extend an array?

ie:

schema MyApp:
   args: [str] = ["default", "args"]

app = MyApp {
   args: args + ["additional", "args"] // how to syntactically support adding new items to an array?
}
Peefy commented 4 months ago

Just use the += operator

schema MyApp:
   args: [str] = ["default", "args"]

app = MyApp {
   args += ["additional", "args"]
}
d4v1d03 commented 4 months ago

Hey @Peefy, #348 PR made.