_ = require 'underscore'
a = {name:'Taro', luckyNumbers:[12,67,42]}
b = {name:'Taro', luckyNumbers:[12,67,42]}
console.log a is b
console.log _.isEqual a,b
実行結果
$ coffee isEqual.coffee
false
true
isEmpty
_.isEmpty(object)
isEmptyは、objectが空の場合にtrueを返します。
_ = require 'underscore'
a = {}
b = {a}
console.log _.isEmpty a
console.log _.isEmpty b
実行結果
$ coffee isEmpty.coffee
true
false
isElement
_.isElement(object)
isElementは、オブジェクトがDOM要素である場合にtrueを返します。
alert _.isElement(jQuery('body')[0]);
実行結果
true
ブラウザでjQueryを読み込んで、実行します。
isArray
_.isArray(object)
isArrayは、objectが配列のときtrueを返します。
_ = require 'underscore'
list = [1,2,3,4,5]
obj = {list}
console.log _.isArray list
console.log _.isArray obj
実行結果
$ coffee isArray.coffee
true
false
isObject
_.isObject(value)
isObjectは、objectがオブジェクトの場合、trueを返します。
_ = require 'underscore'
list = [1,2,3,4,5]
obj = {list}
console.log _.isObject list
console.log _.isObject obj
console.log _.isObject 100
$ cabal update
Downloading the latest package list from hackage.haskell.org
$ cabal install yesod-platform
(ダウンロードとコンパイルとインストールログ)
Updating documentation index
/Users/inouetomoyuki/Library/Haskell/doc/index.html
$
$ mkdir Projects && cd !$
$ yesod init
Welcome to the Yesod scaffolder.
I'm going to be creating a skeleton Yesod project for you.
What is your name? We're going to put this in the cabal and LICENSE files.
Your name: Tomoyuki INOUE
Welcome Tomoyuki INOUE.
What do you want to call your project? We'll use this for the cabal name.
Project name: Sample
Yesod uses Persistent for its (you guessed it) persistence layer.
This tool will build in either SQLite or PostgreSQL or MongoDB support for you.
We recommend starting with SQLite: it has no dependencies.
s = sqlite
p = postgresql
mongo = mongodb
mysql = MySQL (experimental)
So, what'll it be? s
That's it! I'm creating your files now...
Generating deploy/Procfile
Generating config/sqlite.yml
(・・・)
Start your project:
cd Sample && cabal install && yesod devel
or if you use cabal-dev:
cd Sample && cabal-dev install && yesod --dev devel
書いてある通りコマンドを実行します。
$ cd Sample && cabal install && yesod devel
開発サーバを起動します。
$ yesod devel
Yesod devel server. Press ENTER to quit
Resolving dependencies...
Configuring Sample-0.0.0...
Rebuilding application...
Preprocessing library Sample-0.0.0...
Preprocessing executables for Sample-0.0.0...
Preprocessing test suites for Sample-0.0.0...
Building Sample-0.0.0...
Registering Sample-0.0.0...
Starting development server: runghc -package-confdist/package.conf.inplace devel.hs
Starting devel application
Devel application launched: http://localhost:3000