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

String definitions for empty tuple [] and for default empty array = [] #1169

Open
Dimava opened this issue Oct 11, 2024 · 1 comment
Open
Labels
confirmed The maintainers of the repo would like to address this enhancement New feature or request

Comments

@Dimava
Copy link
Contributor

Dimava commented Oct 11, 2024

Request a feature

🤷 Motivation

In 90% of cases when you want to initialize array with a default value, it will be an empty array
Having to go for tuple with initializer generates a lot of boilerplate

💡 Solution

Add = [] initializer

scope({
  item: { foo: 'string' },
  currently: ['item[]', '=', () => []],
  suggested: 'item[] = []',
  
  list: 'item[]',
  currently2: ['list', '=', () => []],
  suggested2: 'list = []',
})

This will also allow to use a global () => Array() initializer

@Dimava
Copy link
Contributor Author

Dimava commented Oct 11, 2024

Currently chose to go the generic way

scope({
  'OrA<T>': ['T', '=', () => []],

  item: { foo: 'string' },
  foo: 'OrA<item[]>',
  
  list: 'item[]',
  bar: 'OrA<list>',
})

@ssalbdivad ssalbdivad added enhancement New feature or request confirmed The maintainers of the repo would like to address this labels Oct 12, 2024
@Dimava Dimava changed the title String definitions for default empty array = [] String definitions for empty tuple [] and for default empty array = [] Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed The maintainers of the repo would like to address this enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants