strings method
BlitzMax Forums/BlitzMax Beginners Area/strings method
| ||
Strict Local str:String="***** Hello *****" str.replace("*","=") Print str output: ***** Hello ***** I hope output : ===== Hello ===== |
| ||
The Replace method returns a new string.Strict Local str:String="***** Hello *****" Print str.replace("*","=") Print str str = str.replace("*","=") Print strIt's not easy to find this in the documentation. Look in the Language reference, Strings section. There is a list of string methods, including this one: Replace:String( subString:String,withString:String ) The Replace:String tells you that Replace returns a String value. |
| ||
blitz is a compiled language and hence the objects are immutable. you cannot generally change an object in place. you need to create a new object to replace the existing one. even slices use this feature. str = str.replace("*","=") hands the results of the function to the new str and destroys the 'old' str |
| ||
Thanks, I have understand. |