E07570: must return a String
What went wrong
A function or method is required to return String but returns a different type.
Worked examples
Compilable examples demonstrating this error and the correct fix:
- ek9 -q 779 (Why must certain operators return a value in EK9?)
How to fix it
- Change return type to String
Common causes
- String conversion operator ($) returning wrong type
- Text formatting function type mismatch
See also
Examples
Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.
Fails with E07570: must return a String
#!ek9 defines module error.e07570.bad defines class Label text <- "label" //'$' converts to a String default operator ? operator $ as pure <- rtn as Integer: length text
Fixed: Return a String
#!ek9 defines module error.e07570.good defines class Label text <- "label" default operator ? operator $ as pure <- rtn as String: text
Questions and answers
These Q&A entries show E07570 and its fix:
- Q779: Why must certain operators return a value in EK9?
- Q1256: Create me a Customer record and use the DOUBLE-dollar $$ operator to convert it to a JSON representation — not plain text.
- Q1257: Write me a Booking class with a SINGLE-dollar $ operator that returns a human-readable reservation line — no JSON, just plain text.