Lyricdev
GitHub

LYR-MIG0315

an index that changed twice

hint · spec 14-cli

A note of lyric fix --from-4: s.indexOf(n) gave a character's index or -1; find gives a byte's index or null.

Explanation

A test of the result is exactly contains, and the migration writes it: s.indexOf(n) >= 0 is s.contains(n), s.indexOf(n) == -1 is !s.contains(n).

Any other indexOf is written find, and what it gives has changed twice: a byte's index in place of a character's, and null in place of -1. Take the null with ?? or if, and where the position goes on to count characters, charIndex(byte) gives the character's index.

Example

proposal[LYR-MIG0315] main.lyr:4:14: '"hello".indexOf("l")' gave a character's index or -1; 'find' gives a byte's index or 'null' — take the 'null' with '??' or 'if', and 'charIndex(byte)' gives the character's index