콘텐츠로 이동
Xen / docs

문서 검색

한국어 · v0.1.0-demo.2

검색어를 입력하세요.

    EN
    Xen / examples v0.1.0-demo.2

    파일 나누기

    파일 나누기

    저장소나 배포본의 루트에서 실행합니다. xen을 PATH에 추가하거나 ./bin/xen으로 바꾸세요.

    터미널 창
    xen check examples/modules/app.xen
    xen run examples/modules/app.xen
    tea: 3
    modules/app.xen
    // SPDX-License-Identifier: MIT OR Apache-2.0
    module app;
    import shop.model as model;
    import shop.view as view;
    fn main() {
    let item = model.Item { name: "tea", price: 3 };
    view.show(item);
    }

    파일 다운로드

    세 파일을 아래 구조로 함께 저장하세요. shop 모듈은 보조 파일이며 직접 실행하지 않습니다.

    examples/modules/
    ├── app.xen
    └── shop/
    ├── model.xen
    └── view.xen
    // SPDX-License-Identifier: MIT OR Apache-2.0
    module shop.model;
    struct Item { name: String, price: Int }

    shop/model.xen

    // SPDX-License-Identifier: MIT OR Apache-2.0
    module shop.view;
    import shop.model as model;
    fn show(item: model.Item) {
    println(item.name + ": " + int_to_str(item.price));
    }

    shop/view.xen