Skip to content

Language: Support null in arrays #16

@tomsontom

Description

@tomsontom

Currently the language does not allow one to express that an entry in an array can be null.

Currently we can express

  • Array is optional: name?: string[]
  • Array is nullable: name: string[]?
  • Array is optional and nullable: name?: string[]?

Possible construct:

  • string?[] - might look strange if string?[]? - not sure we can express it in the grammer
  • string() - looks like a function call
  • nullable<string>[] - eats another keyword and from an editing point of view it feels wrong
  • string | null[] - feels wrong because then we'd express null always using | null instead of ?

another option might be that we change the syntax to create defined an array:

  • array<string> - array of strings
  • array<string>? - array of strings or null
  • array<string?> - array of strings/null
  • array<string?>? - arrary of string/null or null

this has the disavantage that for the default case the string[] this looks strange and unnatural and we'd add another keyword to the language

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions