This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 44fd02c393 GROOVY-11151: Example in the Documentation of the Coercion
Operator is Wrong
44fd02c393 is described below
commit 44fd02c393b9d2daef7b33b5c58a2d3aac4d0ff2
Author: Paul King <[email protected]>
AuthorDate: Tue Aug 8 14:39:44 2023 +1000
GROOVY-11151: Example in the Documentation of the Coercion Operator is Wrong
---
src/spec/doc/core-operators.adoc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/spec/doc/core-operators.adoc b/src/spec/doc/core-operators.adoc
index 949e92477d..944db3f057 100644
--- a/src/spec/doc/core-operators.adoc
+++ b/src/spec/doc/core-operators.adoc
@@ -824,7 +824,7 @@ being compatible for assignment. Let's take an example:
----
include::../test/OperatorsTest.groovy[tags=coerce_op_cast,indent=0]
----
-<1> `Integer` is not assignable to a `String`, so it will produce a
`ClassCastException` at runtime
+<1> `String` is not assignable to an `Integer`, so it will produce a
`ClassCastException` at runtime
This can be fixed by using _coercion_ instead:
@@ -832,7 +832,7 @@ This can be fixed by using _coercion_ instead:
----
include::../test/OperatorsTest.groovy[tags=coerce_op,indent=0]
----
-<1> `Integer` is not assignable to a `String`, but use of `as` will _coerce_
it to a `String`
+<1> `String` is not assignable to an `Integer`, but use of `as` will _coerce_
it to an `Integer`
When an object is coerced into another, unless the target type is the same as
the source type, coercion will return a
*new* object. The rules of coercion differ depending on the source and target
types, and coercion may fail if no conversion