![]() |
Delphi - always full of surprises!
After all these years, Delphi still surprises me. Apparently, as I found out today (by making a stupid typo), Copy(string, index, position) doesn't require position parameter!
IOW, following two lines do exactly the same: s := Copy('123456789', 4, 6); s := Copy('123456789', 4); Works for arrays, too! Of course, this is not ![]() See for yourself: program ProjectCopy; {$APPTYPE CONSOLE} {$R *.res} uses SysUtils; var s1: TArray; begin Writeln(Copy('123456789', 4, 6)); Writeln(Copy('123456789', 4)); s1 := ['1', '2', '3']; Writeln(string.Join(',', Copy(s1, 1, 2))); Writeln(string.Join(',', Copy(s1, 1))); Readln; end. This code outputs (in Tokyo): 456789 456789 2,3 2,3 I'd suspect that this goes waaaaaay back. I tested string version with XE2 and it works the same as in Tokyo. [SIZE=-2]--- Published under the ![]() ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:36 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz