TGViewer
Tact Kitchen Tact Kitchen @tact_kitchen · 505 subscribers
Post #37 494
⚡️ Added destructuring statements

It's a concise way to unpack Structs and Messages into distinct variables, which mirrors the instantiation syntax:

// Definition of Example
struct Example { number: Int }

fun basic() {
// Basic syntax of destructuring assignment
// is shown on the left of "=":
let Example { number } =
Example { number: 42 };

// The syntax above is roughly equivalent
// to the following statements:
let example = Example { number: 42 };
let number = example.number;
}


One can also create bindings under different variable names or ignore some of the fields. Note, that the order doesn't matter:

// "first" goes first, then goes "second"
struct Two { first: Int; second: String }

// a helper function
fun makeTwo(): Two {
return Two {
first: 42,
second: "yee-haw",
};
}

// 👀
fun totalDestruction() {
// The "first" field is ignored,
// while the value of "second"
// is bound under the "cowboy"
// variable from now on:

let Two {
second: cowboy,
first: _,
} = makeTwo();
}


🧑‍🍳 Contributors: Gusarich, Novus Nota (docs)
🐙 Implementation: #856
🍽 To be released in: v1.6.0

🍲 everyone within a 100 mile radius after you eat a taco
♨️ @tact_kitchen
  • ⚡ 11
More from @tact_kitchen
  1. May 30, 2025🎉 Tact Language Server & VS Code Extension v0.8.0 are live! Smarter code insight, TL-B su…
  2. May 28, 2025🎉 Tact v1.6.12 is released! This is another joint release: both v1.6.11 and v1.6.12 were…
  3. May 22, 2025We’ve launched the ultimate hunt for bugs and hacker mastery — the epic CTF has begun at p…
  4. May 19, 2025🎉 Tact v1.6.10 is released! Recently, TVM version 10 was rolled out in the mainnet. It in…
  5. May 7, 2025For you all, JetBrains IDEs lovers: intelli-tact plugin release 📸 🍲 got IDEA? ♨️ @tact_k…
  6. May 7, 2025🎉 Tact v1.6.7 is released! We've been listening to your feedback and analyzing the code w…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →