Penflip

Penflip - Write better with others

  • Loading...
  • Discover Projects
  • Help
  • Signup
  • Login
  • Welcome back!
    No account? Signup Close
    Ready to write better?
    Have an account? Login Close

sarojaba · Rust Doc Korean

Make Changes
46

5.5. 만약에 (if) - 90%

Rust's take on if is not particularly complex, 그러나 전통적인 시스템 언어보다 동적 타입 언어에서의 if와 비슷할 것입니다. 이에 대해 더 이야기해봅시다, to make sure you grasp the nuances.

if는 일반적인 개념인 ‘분기(branch)’의구체화된 형식입니다. 나무의 가지에서 이름을 따왔고, 선택에따라 다양한 경로가 취해질 수 있는 결정 포인트 역할을 합니다.

if의 경우, 하나의 결정에 두개의 경로가 따라옵니다.

let x = 5;

if x == 5 {
    println!("x is five!");
}

만약 무언가 하기 위해 x의 값을 변경했다면, 이 라인은 출력되지 않을 것입니다. 더 자세히, 만약 if 다음에 오는 식이 true으로 평가된다면, 블록은 실행됩니다. false라면, 그렇지 못합니다.

false인 경우에 어떤일이 벌어지길 원한다면, else를 사용하세요.

let x = 5;

if x == 5 {
    println!("x is five!");
} else {
    println!("x is not five :(");
}

하나의 경우가 더 있다면, else if를 사용하세요.

let x = 5;

if x == 5 {
    println!("x is five!");
} else if x == 6 {
    println!("x is six!");
} else {
    println!("x is not five or six :(");
}

이렇게 하는 것은 정말 표준적인 방식입니다. 하지만, 이렇게도 할 수 있습니다.

let x = 5;

let y = if x == 5 {
    10
} else {
    15
}; // y: i32

또는 이와 같이 작성할 수도 있습니다.

let x = 5;

let y = if x == 5 { 10 } else { 15 }; // y: i32

This works because if is an expression. The value of the expression is the
value of the last expression in whichever branch was chosen. An if without an
else always results in () as the value.

Updated by ziriso over 4 years (view history)
5.4. 주석 (Comments) - 80% 5.6. for 반복문 (for Loops) - 100%

Contents

    Rust 문서 한글화 프로젝트 1. 소개(Introduction) - 100% 2. 시작하기(Getting Started) - 100% 2.1. Rust 설치하기 (Installing Rust) - 100% 2.2. 안녕, 세상아! (Hello, world!) - 80% 2.3. 안녕, 카고! (Hello, Cargo!) - 60% 3. Rust 배우기 (Learn Rust) - 100% 3.1. 추리 게임 (Guessing Game) - 40% 3.2. 철학자들의 만찬 (Dining Philosophers) - 0% 3.3. Rust에 다른 언어 포함하기 (Rust Inside Other Languages) - 0% 4. 효과적인 Rust (Effective Rust) - 100% 4.1. 스택과 힙 (The Stack and the Heap) - 5% 4.2. 테스팅 (Testing) - 50% 4.3. 조건적 컴파일 (Conditional Compilation) - 0% 4.5. 반복자 (Iterators) - 0% 4.6. 동시성 (Concurrency) - 0% 4.7. 오류 처리 (Error Handling) - 90% 4.8. 외부 함수 인터페이스 (Foreign Function Interface) - 0% 4.9. Borrow and AsRef 4.10. 릴리즈 채널 (Release Channels) - 0% 5. 문법과 의미 (Syntax and Semantics) - 100% 5.1. 변수 바인딩 (Variable Bindings) - 80% 5.2. 함수 (Functions) - 50% 5.3. 기본형 (Primitive Types) - 90% 5.4. 주석 (Comments) - 80% 5.5. 만약에 (if) - 90% 5.6. for 반복문 (for Loops) - 100% 5.7. while 반복문 (while Loops) - 100% 5.8. 소유권 (Ownership) - 100% 5.9. 참조와 빌림 (References and Borrowing) - 100% 5.10. 수명 (Lifetimes) 5.11. 가변성 (Mutability) - 99% 5.12. 구조체 (Structs) - 0% 5.13. 열거형 (Enums) - 0% 5.14. 정합 (Match) - 99% 5.15. 패턴 (Patterns) - 0% 5.16. 메소드 문법 (Method Syntax) - 0% 5.17. 벡터 (Vectors) - 100% 5.18. 문자열(Strings) - 20% 9. 용어 색인 (Concordance) Show all
    Discussions 5 Pending changes 5 Contributors
    Download Share

    Download

    Working...

    Downloading...

    Downloaded!

    Download more

    Error!

    Your download couldn't be processed. Check for abnormalities and incorrect syntax. We've been notified of the issue.

    Back

    Download PDF Download ePub Download HTML Download Word doc Download text Download source (archive)

    Close
228 Words
1,202 Characters

Share

Collaborators make changes on their own versions, and all changes will be approved before merged into the main version.

Close

Penflip is made by Loren Burton
in Los Angeles, California

Tweet

    About

  • Team
  • Pricing
  • Our Story

    Quick Start

  • Markdown
  • Penflip Basics
  • Working Offline

    Support

  • Help
  • Feedback
  • Terms & Privacy

    Connect

  • Email
  • Twitter