Drkcore

09 02 2012 coffeescript Tweet

CoffeeScriptのswitch文で(Rubyのように)多値を取る方法が分からない

Rubyのようにこんな感じに書きたいのだけど

switch Math.floor(Math.random()*100)
  when 0..30  then console.log('small')
  when 31..60 then console.log('middle')
  else             console.log('large')

そうすると、

Error: In test.coffee, Parse error on line 2: Unexpected '..'

と怒られるのです。

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021