Skip to content

Commit b2fba42

Browse files
author
Bernard Pietraga
committed
Add exercise 1 from chapter 23
1 parent 2537899 commit b2fba42

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

chapter_23/more_cool_stuff_1.exs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
defmodule ParseSygil do
2+
def sigil_z(lines, _options) do
3+
String.rstrip(lines)
4+
|> String.split("\n")
5+
|> Enum.map(&String.split(&1, ","))
6+
end
7+
end
8+
9+
ExUnit.start
10+
11+
defmodule ParseSygilTest do
12+
import ParseSygil
13+
use ExUnit.Case
14+
15+
test "parse CSV like string" do
16+
expected = ~z"""
17+
1,2,3
18+
cat,dog
19+
"""
20+
21+
assert expected == [["1", "2", "3"], ["cat", "dog"]]
22+
end
23+
24+
end

0 commit comments

Comments
 (0)