Skip to content


?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

func abcd(_ distance : Int) {

    var distance = distance  //이게 가능하던데...

    distance  = 1

    print(distance) //파라메터

    print(distance) //위에서 선언한 변수 

}

 

abcd(25)

//이렇게 했을 시 출력이

//25

//1

//이렇게 나오게 하려면 어떻게 해줘야할까요??ㅠ

 

  • ?

    var distance = distance 이후엔 선언한 변수만 사용되고 파라미터를 사용할 수 없습니다.

    다르게 사용하고 싶다면 var innerDistance = distance 와 같이 다른 이름의 변수로 사용해야 합니다.

  • ?

    func abcd(_ distance : Int) {
        print(distance)

        var distance = distance

        distance  = 1

        print(distance) 

    }

    변수명 변경을 안한다면...

    함수 안에서 distance 선언하기전에 print 하는 수밖에 없을것 같네요


                    
  1. iOS개발질문방 이용안내 (등록포인트:100, 답변:100, 추천: 500)

    Date2015.03.01 By아이폰데브 Reply1 Views2319 Votes8
    read more
  2. 로그인 된 애플 계정의 국가를 알 수 있나요?

    Date2022.09.19 CategoryiOS 일반 By여러가지개발 Reply1 Views80 Votes0
    Read More
  3. DateFormatter() 관련 문의 드립니다.

    Date2022.09.19 CategorySwift문법 By유태훈 Reply5 Views92 Votes0 file
    Read More
  4. dismiss all view controllers

    Date2022.09.19 CategoryiOS 일반 ByDev_Kim Reply2 Views148 Votes0
    Read More
  5. ATT권한 메시지 안나오는 이유

    Date2022.09.18 CategoryiOS 일반 ByDeque Reply1 Views90 Votes0 file
    Read More
  6. ios 16 ad-hoc 배포 문의

    Date2022.09.16 CategoryiOS 일반 By룡룡 Reply1 Views287 Votes0
    Read More
  7. 안녕하세요. ios16이 적용된 휴대폰에서는 앱 튕김이 발생합니다.

    Date2022.09.14 CategoryiOS 일반 ByUSIM Reply3 Views640 Votes0
    Read More
  8. .photoLibrary 권한 관련 문의 드립니다.

    Date2022.09.14 CategoryiOS 일반 By유태훈 Reply1 Views75 Votes0 file
    Read More
  9. Universal Links에서 앱이 설치되지 않았을때 앱스토어 리다렉트에 대해서 질문드려요

    Date2022.09.13 CategoryiOS 일반 By주닝닝 Reply0 Views61 Votes0
    Read More
  10. 위젯 만들려면 swiftUI를 공부해야 되나요?

    Date2022.09.13 CategoryiOS 일반 Byios초보중의초보 Reply1 Views142 Votes0
    Read More
  11. loadview에서 [super loadview]를 안쓰고 interface builder에 있는뷰컨트롤러을 가져올 수 있을까요

    Date2022.09.08 CategoryObjective-C Byhelloworrldd Reply1 Views83 Votes0
    Read More
  12. 블루투스 클래식 개발문의 드립니다.. IOS 13부터는 안된다고해서.. 헤매고 있습니다.

    Date2022.09.07 CategoryiOS 일반 By하울 Reply1 Views93 Votes0 file
    Read More
  13. then과 foreach 함께 사용할때 질문

    Date2022.09.04 CategorySwift문법 By울릉 Reply1 Views179 Votes0
    Read More
  14. UIImageView 에 웹 이미지 표시 문의 드립니다.

    Date2022.09.03 CategoryiOS 일반 BydevSimba Reply2 Views102 Votes0
    Read More
  15. CollectionView Cell Shadow 관련 질문

    Date2022.09.01 CategorySwift문법 By유월 Reply1 Views88 Votes0 file
    Read More
  16. 하이브리드 앱(IOS 패키징) 속도 관련 문의

    Date2022.09.01 CategoryiOS 일반 By손승희 Reply1 Views143 Votes0
    Read More
  17. webview history 관리 질문 드립니다.

    Date2022.08.31 CategoryiOS 일반 By호따구 Reply1 Views247 Votes0
    Read More
  18. 함수 내에 함수 파라메터와 같은 이름의 변수를 선언하면 함수내에서 둘을 어떻게 구분 하나요??

    Date2022.08.25 CategorySwift문법 ByhAute2 Reply2 Views137 Votes0
    Read More
  19. RxSwift / MVVM에서 화면(데이터) 갱신 문의

    Date2022.08.24 CategoryiOS 일반 By유태훈 Reply2 Views156 Votes0 file
    Read More
  20. stackview 내부 view들 유동적으로 height 조절하기..

    Date2022.08.23 CategoryiOS 일반 Byp2noo Reply0 Views135 Votes0
    Read More
  21. ios 웹뷰에서 호출하는 네이티브 브릿지 메소드의 파라미터값에 길이제한이 있나요?

    Date2022.08.17 CategoryiOS 일반 By여름나무1015 Reply2 Views166 Votes0
    Read More
Board Pagination Prev 1 ... 6 7 8 9 10 11 12 13 14 15 ... 139 Next
/ 139
회원수   전체 : 14,412   오늘 : 0   어제 : 2   |   방문자수   전체 : 3,372,526   오늘 : 935   어제 : 2,398   |   페이지뷰   전체 : 46,935,011   오늘 : 2,013   어제 : 4,441  

 
© 스위프톡. All Rights Reserved.

sketchbook5, 스케치북5

sketchbook5, 스케치북5

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소