[Solved] [Sophia] How to unpack tuple


#1

Why can’t I unpack tuple in a way specified by this documentation?

For example this does not compile:

let t = ("ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU", 100)
let (addr, amount) = t

Parse error, unexpected token ‘(’ in second line.

I’m using [email protected] which runs aeternity/aeternity nodes (docker hub).


#2

@piwo should be able to help here. I will ping him.


#3

Hey, you can only do pattern matching using switch, so

switch(tuple)
  (first, second) => ???

#4

Also I just noticed that the documentation you referenced is very outdated as it was created based on reasonml when Sophia wasn’t finished yet, we’ll fix this (cc @pegah)