Substring/Top and tail: Difference between revisions
Content deleted Content added
No edit summary |
|||
Line 1,230: | Line 1,230: | ||
o̲s̲ |
o̲s̲ |
||
</pre> |
</pre> |
||
=={{header|Smalltalk}}== |
|||
{{works with|GNU Smalltalk}} |
|||
These all use built-in collection methods that will work with any kind of ordered collection, not just Strings. There is no error checking. They will fail if the string is not at least two characters long. |
|||
<lang smalltalk> |
|||
s := 'upraisers'. |
|||
Transcript show: 'Top: ', s allButLast; nl. |
|||
Transcript show: 'Tail: ', s allButFirst; nl. |
|||
Transcript show: 'Without both: ', s allButFirst allButLast; nl. |
|||
Transcript show: 'Without both using substring method: ', (s copyFrom: 2 to: s size - 1); nl. |
|||
</lang> |
|||
{{out}} |
|||
<pre> |
|||
Top: upraiser |
|||
Tail: praisers |
|||
Without both: praiser |
|||
Without both using substring method: praiser </pre> |
|||
=={{header|SNOBOL4}}== |
=={{header|SNOBOL4}}== |