Liquidsoap提供string.replace
功能。但是我应该如何使用呢?似乎期望将函数作为第二个参数进行替换。
我想做这样的事情:
str = "Hello world."
str = string.replace(pattern="w", "W", str)
# str == "Hello World."
答案 0 :(得分:0)
string.replace
实际上期望第一个未标记参数的功能。该函数的返回值将用作替换。
示例:
str = "Hello world."
str = string.replace(pattern="w", (fun(_) -> "W"), str)
# str == "Hello World."
内联箭头函数fun(_) -> "W"
是将始终返回"W"
的函数。