Skip to content

Best practice to overriding default value from a definition in another definition? #989

Answered by cueckoo
cueckoo asked this question in Q&A
Discussion options

You must be logged in to vote

Original reply by @mpvl in cuelang/cue#989 (comment)

In general, a good approach is to not have any defaults in the base template, and then add them later as one desires.

In this case, the issue is that bar introduces a disjunction without a default. To ensure it "reaches" the newDefault value, you could write

	bar: #AB | *{ // <---- NOTE THE ADDED DEFAULT MARKER 
		b: #B & {bf: "newDefault"}
	}

Replies: 1 comment

Comment options

cueckoo
Jul 3, 2021
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by cueckoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant