Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support item assignment with lists and dicts like ${x}[key] = Keyword #4546

Closed
pekkaklarck opened this issue Nov 25, 2022 · 1 comment · Fixed by #4727
Closed

Support item assignment with lists and dicts like ${x}[key] = Keyword #4546

pekkaklarck opened this issue Nov 25, 2022 · 1 comment · Fixed by #4727
Milestone

Comments

@pekkaklarck
Copy link
Member

These aren't currently supported:

${dict} =    Create Dictionary    key=initial
${dict}[key] =    Set Variable    new

${list} =    Create List    one    two
${list}[0] =    Set Variable    new

Especially setting dictionary items would be useful, but there certainly are cases where setting list items is convenient as well. In fact, this syntax should work with any object that has __setitem__.

Things to take into account:

  • It should be possible to specify the key/index as a variable like ${x}[${y}].
  • It should be possible to give list indices as strings and as integers.
  • Lists should support slices.
  • Error message should be clear if the item is immutable (tuple, string, immutable mapping, ...).

This would be a convenient feature, but because it's possible to manipulate lists and dicts with Collections keywords I don't consider this high priority. See also #4545 that proposes supporting ${x${y}} = Keyword and also contained this enhancement in it initially.

@pekkaklarck
Copy link
Member Author

We have a great PR #4727 by @Vincema implementing this. Let's include this still in RF 6.1.

@pekkaklarck pekkaklarck added the acknowledge To be acknowledged in release notes label May 17, 2023
pekkaklarck pushed a commit that referenced this issue May 23, 2023
@pekkaklarck pekkaklarck changed the title Support item assigment with lists and dicts like ${x}[key] = Keyword Support item assignment with lists and dicts like ${x}[key] = Keyword Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants