mirror of
https://github.com/polserver/polserver
synced 2026-08-13 08:23:08 -04:00
17 lines
450 B
Text
17 lines
450 B
Text
|
|
// Subtracting a string removes its first occurrence.
|
||
|
|
var s := "hello world";
|
||
|
|
print( s - "l" );
|
||
|
|
print( s - "o w" );
|
||
|
|
print( s - "not there" );
|
||
|
|
print( s - "" );
|
||
|
|
|
||
|
|
// Subtracting anything else hands back the string unchanged.
|
||
|
|
print( s - 1 );
|
||
|
|
print( s - 1.5 );
|
||
|
|
print( s - { 1, 2 } );
|
||
|
|
|
||
|
|
// A method the compiler does not know is looked up by name at runtime, and a string has
|
||
|
|
// no such method to offer.
|
||
|
|
var unknown := s.no_such_method();
|
||
|
|
print( unknown );
|