Skip to content
This repository has been archived by the owner on Jan 17, 2021. It is now read-only.

Commit

Permalink
Update sample code in README
Browse files Browse the repository at this point in the history
  • Loading branch information
guoye-zhang committed Oct 31, 2017
1 parent c249d98 commit 55a36ed
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ f5: (int32, int32) -> binaryop

**Usage (Swift)**
```Swift
let encoding = f1Encode { o1, o2, o3 in
minus(
add(o1, 2 as Int32),
add(o2, o3)
)
}
```
```Swift
class Implementation: Symbols {
func add(_ o1: Int32, _ o2: Int32) -> Int32 {
return o1 + o2
Expand All @@ -35,11 +43,7 @@ class Implementation: Symbols {
}
}

// protobuf message
let encoding = f1Encode { o1, o2, o3 in minus(add(o1, 2 as Int32), add(o2, o3)) }

let function = f1Decode(function: encoding, symbols: Implementation())

assert(function(1, 2, 3) == -2)
```

Expand Down

0 comments on commit 55a36ed

Please sign in to comment.