|
Oktatás * Programozás 1 * Szkriptnyelvek Teaching • Programming 1 (BI) Félévek Linkek * kalendárium |
Nim2 /
removePrefix, removeSuffixSee also std/strutils Python also has these two string methods. However, in Python, they return a new string object. In Nim, they modify the string in-place. If you want a Python-like behaviour, you can do that with a custom function. removePrefix()
removeSuffix()Can be done similarly to Using dup from std/sugarI learned later about the My only problem is the strange syntax when using import std/strutils import std/sugar # dup let url = "https://python.org" # let, immutable url2 = url.dup # makes a copy # --- naked1 = url.dup(removePrefix("https://")) # python.org naked2 = url.dup removePrefix("https://") # python.org naked3 = dup url: removePrefix("https://") # python.org naked4 = url.dup: removePrefix("https://") # python.org echo url # https://python.org echo url2 # https://python.org echo naked1 # python.org echo naked2 # python.org echo naked3 # python.org echo naked4 # python.org Maybe |
![]() Blogjaim, hobbi projektjeim * The Ubuntu Incident [ edit ] |
||||