Skip to content

Advanced return type (tuple) - how to use? #5532

Discussion options

You must be logged in to vote

Does this mean I can test if my pupils have a function which properly returns tuples instead of lists?

Yes, this is possible.

I've tried (mimicking the full example)

It seems these docs are slightly out-of-date: they are missing a required YAML tag. My apologies for that.

There are a few equivalent ways of doing this:

- expression: RGB((0, 128, 128))
  return: !expression "(255, 127, 127)"
- expression: RGB((0, 128, 128))
  return: !expression "tuple((255, 127, 127))"
- expression: RGB((0, 128, 128))
  return: !tuple [255, 127, 127]
- expression: RGB((0, 128, 128))
  return: !tuple
    - 255
    - 127
    - 127

You are correct that your last example will accept both list and tuple in …

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by bmesuere
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5531 on May 15, 2024 16:18.