Modeling Maps #311
Answered
by
bioball
ericzbeard
asked this question in
Q&A
Modeling Maps
#311
-
I'm wondering if it's possible to have a strongly typed map that lets me use object syntax, so I can avoid the extra typing involved with Here's an example: class Widget {
Name: String
}
class A {
Props: Mapping<String, Widget>
}
// Valid
a: A = new {
Props {
["Foo"] {
Name = "widget a"
}
}
}
// Valid
aa: A = new {
Props {
["Foo"] = new Widget {
Name = "widget aa"
}
}
}
// Invalid but this is what I want (less verbose)
aaa: A = new {
Props {
Foo {
Name = "widget aaa"
}
}
} |
Beta Was this translation helpful? Give feedback.
Answered by
bioball
Mar 11, 2024
Replies: 1 comment 3 replies
-
This isn't possible; it was actually an intentional design goal to separate the grammar for these two. The intention is that you can unambiguously tell which keys are not fixed when reading through Pkl code. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
ericzbeard
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This isn't possible; it was actually an intentional design goal to separate the grammar for these two. The intention is that you can unambiguously tell which keys are not fixed when reading through Pkl code.