Skip to content

Add "extend" to help putting multiple items from one list into another #687

Description

@ctheune

In Python we have "list.extend(otherlist)" as a multi-item "append" basic function.

I found that this is a bit tedious in hyperscript (or of course I might be missing something). Especially if I'm parsing something where the result could be a non-list (which is also interesting in its own from a typing perspective that splitting an empty string results in a non-list):

<span data-assignees="a b c"
  _="init
          set $assignees to my @data-assignees split by ' '
          if not $assignees then set $assignees to []" />

I wish I could do this instead:

<span data-assignees="a b c"
  _="init
          set $assignees to []
          extend $assignees with my @data-assignees split by ' '
        " />

We could also consider whether "split by" should always return a list (I'm not quite sure what's going on there when @data-assignees is an empty value) but that's orthogonal to the extend ability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions