Skip to content

In 2D array getting an inner array by variable makes it impossible to get an elem of inner array #766

Description

@Vulwsztyn

Minimal reproducible example:

 (
  $arr := [[], [4, 5]];
  $i := 1; 
  $j := 1; 
  $arr[$i][$j];
)

It should be 1, but I get no match in excerciser.

Image

$arr[1][1]; and $arr[1][$j] work.

Exploring other possibilities:

(
  $arr := [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
  $i := 1;
  $j := 2; 

  $x := $arr[$i];
  {
      "double_variable":$arr[$i][$j],
      "one_variable": $arr[$i],
      "first_variable": $arr[$i][2],
      "second_variable": $arr[1][$j],
      "is_equal": $x[$i] = $arr[$i][$j],
      "separated": $x[$i]
  }
)

results in:

{
  "one_variable": [
    4,
    5,
    6
  ],
  "second_variable": 6,
  "is_equal": false,
  "separated": 5
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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