Menu
Coddy logo textTech

프로젝트: 인벤토리 항목

Coddy Lua 여정의 Luau 소개 섹션에 포함된 레슨 — 73개 중 63번째.

challenge icon

챌린지

쉬움

핵심 타입과 두 개의 아이템을 정의하여 인벤토리 프로젝트를 시작하세요.

  • id: number, name: string 그리고 data: T 필드를 갖는 제네릭 타입 별칭 Item<T>를 선언하세요.
  • id = 1, name = "Iron Sword"data = {damage = 25}를 갖는 Item<{damage: number}> 타입의 sword를 생성하세요.
  • id = 2, name = "Health Potion"data = {heal = 40}을 갖는 Item<{heal: number}> 타입의 potion을 생성하세요.

그런 다음, 각각 한 줄에 하나씩 출력하세요:

  1. sword.id
  2. sword.name
  3. sword.data.damage
  4. potion.id
  5. potion.name
  6. potion.data.heal

직접 해보기

-- 여기에 코드를 작성하세요
-- 1) id, name, data를 가진 제네릭 타입 Item<T>를 선언하세요
-- 2) sword (Item<{damage: number}>)와 potion (Item<{heal: number}>)을 생성하세요
-- 3) 요청된 여섯 개의 필드를 한 줄에 하나씩 출력하세요

Luau 소개의 모든 레슨