1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

string: add map method

This commit is contained in:
Swastik Baranwal
2020-06-17 15:56:55 +05:30
committed by GitHub
parent 5749add670
commit 0052ab71e9
2 changed files with 17 additions and 0 deletions

View File

@ -742,6 +742,19 @@ fn test_double_quote_inter() {
assert '${a} ${b}' == "1 2"
}
fn test_string_map() {
a := 'Hello'.map(fn (b byte) byte {
return b + 1
})
assert a == 'Ifmmp'
assert 'foo'.map(foo) == r'\ee'
}
fn foo(b byte) byte {
return b - 10
}
fn test_split_into_lines() {
line_content := 'Line'
text_crlf := '${line_content}\r\n${line_content}\r\n${line_content}'