Type detection: Difference between revisions
Content added Content deleted
(→{{header|zkl}}: opps) |
(→{{header|zkl}}: added how to use) |
||
Line 50: | Line 50: | ||
text:=data_or_fileName.text; //-->String |
text:=data_or_fileName.text; //-->String |
||
doTheActualTextProcessing(text); |
doTheActualTextProcessing(text); |
||
} |
|||
}</lang> |
|||
fcn doTheActualTextProcessing(text){ println(text) }</lang> |
|||
If an int is passed in, (123).text --> "123", other objects might throw an exception. |
If an int is passed in, (123).text --> "123", other objects might throw an exception. |
||
How to use: |
|||
<lang zkl>processText("foo.txt"); |
|||
processText(Data(Void,"This is some text")); |
|||
// fake up a class that holds a string: |
|||
cs:=class{ var text }; cs.text="this is more text"; |
|||
processText(cs);</lang> |
|||
{{out}} |
|||
<pre> |
|||
this is foo.txt |
|||
This is some text |
|||
this is more text |
|||
</pre> |