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

Initialize an array with and update applied of another array as map does #22834

Open
2 tasks
jorgeluismireles opened this issue Nov 11, 2024 · 0 comments
Open
2 tasks
Labels
Feature Request This issue is made to request a feature.

Comments

@jorgeluismireles
Copy link

jorgeluismireles commented Nov 11, 2024

Describe the feature

From the https://docs.vlang.io/v-types.html#map-update-syntax maps can be formed with the next following ...base_map syntax:

const base_map = {
	'a': 4
	'b': 5
}

const base_array = [
	1
	2
]

fn main() {
	complete_map := {
		...base_map
		'b': 88
		'c': 99
	}
	complete_array := [
		...base_array // error: invalid expression: unexpected token `...`
		3
		4
	]
}

Implement the same idea for arrays. Above line ...base_array is not accepted.

Use Case

Accommodate several const arrays in larger ones for testing use cases making groups from parts.

Preventing use mutable cloning as map doc says

This is functionally equivalent to cloning the map and updating it, except that you don't have to declare a mutable variable.

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

V 0.4.8 e433d7c

Environment details (OS name and version, etc.)

Tested at current https://play.vlang.io/

Huly®: V_0.6-21279

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@jorgeluismireles jorgeluismireles added the Feature Request This issue is made to request a feature. label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

1 participant