Newbie question on overriding values #1177
                  
                    
                      spastorclovr
                    
                  
                
                  started this conversation in
                General
              
            Replies: 2 comments 2 replies
-
| 
         I have actually managed to do this by using Is it the way to go? Feels a bit cumbersome.  | 
  
Beta Was this translation helpful? Give feedback.
                  
                    0 replies
                  
                
            -
| 
         Pkl's way to do this is by either amending, or assigning. class App2 {
    name: String
    list: Listing<Int>
}
baseApp: App2 = new {
   name = "toto"
   list { 1; 2 }
}
child: App2 = (baseApp) {
  list = new { 1; 2; 3 } // overwrite `list`
}
child2: App2 = (baseApp) {
  list { 1; 2; 3 } // amend parent `list`
}See output here: https://pkl-playground.vercel.app/?share=suppose-friend-food Also, by the way,  class App2 {
    name: String
    // bad; when defining a class property, don't also provide its data
    list: Listing<Int> = new { 1; 2; 3 }
} | 
  
Beta Was this translation helpful? Give feedback.
                  
                    2 replies
                  
                
            
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there 👋
I coming from KCL land, where you have options to merge or replace value using either ":" or "=" when assigning values to variable.
I was wondering how this could be achieve in Pkl?
for instance, how could I have child having only the value "10" in its property list ?I want to replace and not merge.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions