Skip to content

손영빈 // 기존코드 객체화 진행#10

Open
ybin4548 wants to merge 5 commits into
yeongbin_devfrom
yeongbin_obj
Open

손영빈 // 기존코드 객체화 진행#10
ybin4548 wants to merge 5 commits into
yeongbin_devfrom
yeongbin_obj

Conversation

@ybin4548
Copy link
Copy Markdown
Collaborator

@ybin4548 ybin4548 commented Jan 15, 2026

기존 코드 수정, 객체화 진행했습니다.
기본적으로, 코드는 지난번에 사용된 코드를 거의 그대로 사용하도록 구현했습니다.
지난 코드와 비교하실 수 있도록 브랜치 하나 새로 파서 pr 남깁니다.

@ybin4548 ybin4548 changed the title 객체화 손영빈 // 기존코드 객체화 진행 Jan 15, 2026
Comment thread baseballgame/GameInput.swift Outdated
Comment on lines +17 to +20
guard let input = readLine(),
let num = Optional(input.compactMap{Int(String($0))}), //숫자 외의 다른 값이 들어왔는지 확인, map 대신 compactMap 사용 : map 사용시 nil로 처리 되기 때문에 처리가 바르게 일어나지않음(ex. 1ab입력시 num = [1,nil,nil] -> 중복으로 처리됨
num.count == 3
else {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

입력 된 문자열을 처리하는 코드를 guard 안에서 처리하려고 Optinal로 감싸신 것 같은데

let num = readLine().map({ $0.compactMap(\.wholeNumberValue) })

이렇게 처리하면 좋을 것 같네요.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants