Union Type은 타 언어의 Enum Class와 비슷하다. Elm 에서 Union Type을 Tag 라고도 부른다. 선언 방법 type Answer = Yes | No 활용 예시 respond : Answer -> String respond answer = case answer of Yes -> "Good" No -> "Bad" > respond Yes "Good" : String > respond No "Bad" : String 포함 하기 Union Type은 관련된 정보를 포함할 수 있다. type Answer = Yes | No | Other String Other 태그는 String을 포함한다. 정의되었던 respond 함수를 다음과 같이 호출할 수 있다. respond : Answer ->..
[Elm] 유니온 타입 (Union Type)
Union Type은 타 언어의 Enum Class와 비슷하다. Elm 에서 Union Type을 Tag 라고도 부른다. 선언 방법 type Answer = Yes | No 활용 예시 respond : Answer -> String respond answer = case answer of Yes -> "Good" No -> "Bad" > respond Yes "Good" : String > respond No "Bad" : String 포함 하기 Union Type은 관련된 정보를 포함할 수 있다. type Answer = Yes | No | Other String Other 태그는 String을 포함한다. 정의되었던 respond 함수를 다음과 같이 호출할 수 있다. respond : Answer ->..
2020.11.24