Wire: String:replace("","") always returns an empty string

Created on 12 Jan 2017  路  7Comments  路  Source: wiremod/wire

Title says it all really, heres some sample code anyway.

@name Rep Test
print(">"+"Hi":replace("",""))
Bug Garry's fault Won't fix

Most helpful comment

@bigdogmat i was just stating a fact, not implying an opinion.

All 7 comments

Empty string matches any character. Try string.find("hello","")

Empty string matches any character. Try string.find("hello","")

Why is this relevant? Only reason this returns an empty string is because here we return an empty string if given an empty needle.

That check can be removed as it won't crash anymore. Or it could be changed to just return the string itself, would do the same as calling string.Replace except skips that step.

Strange that "" matches anything, do you think we could get it to just return the input as techically replacing any char with itself should't change anything.

@TomyLobo Do you not agree that it still should return itself and not an empty string? Also I've already said that it won't crash anymore,

That check can be removed as it won't crash anymore. Or it could be changed to just return the string itself, would do the same as calling string.Replace except skips that step.

@TomyLobo

Can you tell what exactly can crash if this is removed, because I see only 邪 value assign. Moreover. Just a return statement. The interpreter will not even go trough the "this:Replace( needle, new)" statement.

@bigdogmat i was just stating a fact, not implying an opinion.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shadow7483147 picture shadow7483147  路  4Comments

TAbdiukov picture TAbdiukov  路  5Comments

CaptainPRICE picture CaptainPRICE  路  7Comments

CaptainPRICE picture CaptainPRICE  路  8Comments

Etothepowerof26 picture Etothepowerof26  路  5Comments