Open ilyash-b opened 2 years ago
I`m on it
Bonus tasks: in addition to Pfx, this could also be implemented for MaybePfx, Sfx, MaybeSfx, Ifx, MaybeIfx.
Note that Pfx('something') actually returns MustPfx('something')
The difference between Must... and Maybe... is when the prefix/suffix are not present:
Went through issues. This issue is actually a specific case of #301
@ilyash-b Maybe it's better not to create extra keywords for Pfx, MustPfx and etc., but to use function arguments?
str.replace(str, str, bool throw_exception, int max_replaces)'
Or we can provide 2 functions for string object
str.replace(str, str, max_replaces)'
str.strict_replace(str, str, max_replaces) # will throw exception if subseq. not found
What you think?
Maybe it's better not to create extra keywords for Pfx, MustPfx and etc., but to use function arguments?
Pfx
and friends are not keywords (nor parameter names). They are types. Semantically meaningful types. This design is aligned with the overall design of the language.
throw_exception
Not aligned with everything else. No other method takes such parameter (unless I missed.. but they really shouldn't).
max_replaces
- nice idea, need to think about this
str.replace ... str.strict_replace
The overall intention in NGS is to have small amount of verbs (method names) and rely heavily on multiple-dispatch.
What do you think, @Rukopet ?
Old incorrect behavior: