Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code-samples/appendices-examples-test-helper.pony
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fun tag assert_error(test: ITest, msg: String = "") ?
fun tag expect_error(test: ITest box, msg: String = ""): Bool
fun tag assert_is (expect: Any, actual: Any, msg: String = "") ?
fun tag expect_is (expect: Any, actual: Any, msg: String = ""): Bool
fun tag assert_eq[A: (Equatable[A] #read & Stringable)]
fun tag assert_eq[A: (Equatable[A] #read & Stringable #read)]
(expect: A, actual: A, msg: String = "") ?
fun tag expect_eq[A: (Equatable[A] #read & Stringable)]
fun tag expect_eq[A: (Equatable[A] #read & Stringable #read)]
(expect: A, actual: A, msg: String = ""): Bool
2 changes: 1 addition & 1 deletion code-samples/control-structures-iftype-capability.pony
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ actor Main
let cat2: Cat val = Cat
maybe_rename[Cat val](cat2, env)

fun maybe_rename[A: Animal](a: A, env: Env) =>
fun maybe_rename[A: Animal #any](a: A, env: Env) =>
iftype A <: Cat ref then
a.set_name("Kitty")
env.out.print(a.name())
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
class Foo[A: Any]
class Foo[A: Any #any]
2 changes: 1 addition & 1 deletion docs/generics/generics-and-reference-capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the examples presented previously we've explicitly set the reference capabili
--8<-- "generics-foo-with-any-val.pony::1"
```

If the capability is left out of the type parameter then the generic class or function can accept any reference capability. This would look like:
To accept any reference capability, use `#any` as the capability on the constraint. This would look like:

```pony
--8<-- "generics-and-reference-capabilities-explicit-constraint-and-default-capability.pony"
Expand Down
Loading