From 72c1f4dc3f881e17a51093fcea1c892b14b427fb Mon Sep 17 00:00:00 2001 From: Novus Nota <68142933+novusnota@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:32:11 +0200 Subject: [PATCH] fix: applied some suggestions from a code review --- pages/book/cells.mdx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pages/book/cells.mdx b/pages/book/cells.mdx index 4de838d0..e29ecbff 100644 --- a/pages/book/cells.mdx +++ b/pages/book/cells.mdx @@ -105,10 +105,17 @@ Similar to serialization options of [`Int{:tact}`](/book/integers) type, `Cell{: * as fields of [contracts](/book/contracts) and [traits](/book/types#traits), * and as fields of [Structs](/book/structs-and-messages#structs) and [Messages](/book/structs-and-messages#messages). -```tact +```tact {2-3} contract SerializationExample { someCell: Cell as remaining; someSlice: Slice as bytes32; + + // Constructor function, + // necessary for this example contract to compile + init() { + self.someCell = emptyCell(); + self.someSlice = emptySlice(); + } } ``` @@ -116,7 +123,7 @@ contract SerializationExample { To illustrate what `remaining{:tact}` serialization type does, let's take a look at [cell manipulation primitives](#cells-immutability) and their [TL-B][tlb] representation produced by Tact: -```tact +```tact {3-5, 8-10} contract SerializationExample { // By default cRef: Cell; // ^cell in TL-B @@ -127,6 +134,17 @@ contract SerializationExample { cRem: Cell as remaining; // remainder in TL-B bRem: Builder as remaining; // remainder in TL-B sRem: Slice as remaining; // remainder in TL-B + + // Constructor function, + // necessary for this example contract to compile + init() { + self.cRef = emptyCell(); + self.bRef = beginCell(); + self.sRef = emptySlice(); + self.cRem = emptyCell(); + self.bRem = beginCell(); + self.sRem = emptySlice(); + } } ```