Dictionary 값은 무조건 1가지 타입만 정의해야 하나요? #72
Answered
by
M1zz
aroundus
asked this question in
무엇이든 물어보세요!
-
다음과 같이 2가지 타입으로 정의하고 싶어요!
|
Beta Was this translation helpful? Give feedback.
Answered by
M1zz
Sep 2, 2022
Replies: 2 comments
-
어떤 문제를 해결하고 싶어서 저렇게 정의하고 싶은건가요? 혹시 그냥 타입을 여러개 쓰고 싶은걸까요? type castring 이 부분의 Type Casting for Any and AnyObject 를 한 번 보시는 것을 추천 드립니다! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
aroundus
-
Any도 해결책은 될 수 있지만, 강타입 언어인 Swift에서 좋은 해결책은 아닙니다.
정도로 만들어서 [String: Either<Int, String>] = ["철수": .left(100), "영희": .right("090")] 같은 방법으로 표현해보는 것도 좋습니다. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
어떤 문제를 해결하고 싶어서 저렇게 정의하고 싶은건가요?
혹시 그냥 타입을 여러개 쓰고 싶은걸까요?
type castring 이 부분의 Type Casting for Any and AnyObject 를 한 번 보시는 것을 추천 드립니다!