This is ok, because assignment also returns value. What happens here: - seek for a match - if match found, put match data to "match" and go to main branch - if no match found, put undefined to "match" and go to "else" branch
On Tue, 06 Jan 2009 15:27:04 +0300, plattecoducks <fliger.d...@gmail.com> wrote: > > The following looks like a "freshman" error: > > ln347 while (source.length > 0) { > ln348 if (match = source.match(pattern)) { > ln349 result += source.slice(0, match.index); > ln350 result += String.interpret(replacement(match)); > ln351 source = source.slice(match.index + match[0].length); > ln352 } else { > ln353 result += source, source = ''; > ln354 } > ln355 } > > This comes from the latest download, prototype-1.6.0.3.js. Look at > line 348. This type of code is sprinkled throughout the file. > > This is an assignment and not a comparison. Thus the statements will > always execute. > > Can this possibly be correct? Like I said, it looks like a neophyte > error. > > > > -- arty ( http://arty.name ) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---