Skip to content

Commit f18113f

Browse files
committed
Add SimpleApp.StructExample
1 parent 17359c4 commit f18113f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
defmodule SimpleApp.StructExample do
2+
defmodule SomeStruct do
3+
defstruct [name: "John Smith", age: 25]
4+
end
5+
6+
@type t :: %SomeStruct{}
7+
8+
@spec age(t) :: non_neg_integer
9+
def age(%SomeStruct{age: age}), do: age
10+
11+
@spec mistake :: :ok
12+
def mistake do
13+
age(%{first: "John", last: "Smith", age: 32})
14+
end
15+
16+
end

0 commit comments

Comments
 (0)