#author("2019-10-09T14:49:39+09:00","default:ryuichi","ryuichi")
* enum [#r1f46ff1]


*** price.enum.ts [#o0c01a86]
 export enum Price {
     book = 500,
     pen = 120,
     eraser = 80
 }

*** index.ts [#keba55cf]
 import { Price } from './price.enum';
 
 function totalPrice(arg1: Price, arg2: Price) {
     return arg1 + arg2;
 }
 
 console.log(totalPrice(Price.book, Price.pen)); // OK
 console.log(totalPrice(Price.book, 1));         // OK
 console.log(totalPrice(Price.book, 'abc'));     // エラー


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS