Skip to content

put condition judgement in customized func #13400

Answered by jeskew
LiliDeng asked this question in Q&A
Discussion options

You must be logged in to vote

The output type for getOsProfile is non-nullable. Function parameter and output types are enforced by the ARM engine at runtime, so returning null will raise an error. You can allow a null return by using a ? suffix on the return type to make it nullable (i.e., object? instead of object):

func getOsProfile(node object, admin_username string, admin_password string, admin_key_data string) object? => isCvm(node) 
? null
: generateOsProfile(node, admin_username, admin_password, admin_key_data)
...
osProfile: getOsProfile(nodes[i], admin_username, admin_password, admin_key_data)

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@LiliDeng
Comment options

@jeskew
Comment options

@LiliDeng
Comment options

Answer selected by LiliDeng
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #13395 on February 21, 2024 14:47.