Type detection: Difference between revisions

Content added Content deleted
Line 733: Line 733:
s1.writeText()
s1.writeText()
s2.writeText()</lang>
s2.writeText()</lang>

=={{header|ObjectIcon}}==
{{trans|Icon}}
<lang objecticon>import io

procedure main()
print_text("This\nis\na text.\n")
print_text(open("type_detection-oi.icn"))
end

procedure print_text(source)
case type(source) of {
"string" : writes(source)
"object" : while write(source.read())
}
end</lang>
{{out}}
$ oit -s type_detection-oi.icn && ./type_detection-oi
<pre>This
is
a text.
import io

procedure main()
print_text("This\nis\na text.\n")
print_text(open("type_detection-oi.icn"))
end

procedure print_text(source)
case type(source) of {
"string" : writes(source)
"object" : while write(source.read())
}
end</pre>


=={{header|Perl}}==
=={{header|Perl}}==