반응형 function2 [Kotlin] 코틀린 기본 문법 3 (함수) 함수 정의 (Function Definition): Kotlin에서 함수를 정의할 때는 fun 키워드를 사용 fun greet() { println("Hello, Kotlin!") } 매개변수 (Parameters): fun greet(name: String) { println("Hello, $name!") } 함수의 반환 자료형 표기 (Function Return Type Annotation): Kotlin에서 함수의 반환 자료형을 표기하기 위해서는 함수 정의 시 콜론(:) 다음에 반환 자료형을 명시합니다. fun multiply(a: Int, b: Int): Int { return a * b } 함수의 반환 자료형을 추론할 수 있는 경우에는 반환 자료형을 생략할 수도 있습니다. Kotlin 컴파일러는.. 2023. 7. 20. [IOS] [Objective-C] 함수, function, method Implementation 의 함수만들기 예) 파라메터와 리턴값이 없는 것 함수타입(리턴타입)함수명 -(void)printInfo // .h @interface TestUtil : NSObject - (void)printInfo; @end // .m @implementation TestUtil -(void)printInfo{ NSLog(@"hello-bryan"); } @end // 사용 TestUtil *testUtil = [[TestUtil alloc] init]; [testUtil printInfo]; // hello-bryan 예) 파라메터와 리턴값이 있는 것 함수타입(리턴타입)함수명:(파라메터1의 타입)파라메터명 두번째파라메터별칭:(두번째파라메터타입)두번째파라메터명 -(NSString*)setI.. 2022. 2. 8. 이전 1 다음 728x90 반응형