This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // console.logのエイリアス | |
| var l = function(x) { console.log(x) }; | |
| function getWithReturn() { | |
| return "Return"; | |
| } | |
| function getWithNotRetun() { | |
| "NotRetun" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // console.logのエイリアス | |
| var l = function(x) { console.log(x) }; | |
| function Person(name) { | |
| l(this); | |
| this.name = name | |
| } | |
| Person("田中"); // Window | |
| l(name); // 田中 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Person(name) { | |
| this.name = name; | |
| } | |
| Person.prototype.getHelloString = function(toName, greet) { | |
| this.name + ":" + toName + "さん!" + greet; | |
| } | |
| tanaka = new Person("田中"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function Person(name) { | |
| this.name = name; | |
| } | |
| Person.prototype.hello = function(toName, greet) { | |
| console.log(this.name + ":" + toName + "さん!" + greet); | |
| } | |
| Person.prototype.helloTest = function(toName, greet) { | |
| this.name + ":" + toName + "さん!" + greet; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # 【置換前】 | |
| # 〜ですか? | |
| # はいそうです。 | |
| # これは違うのでは? | |
| # いいえ、〜だからです。 | |
| # 【置換後】 | |
| # Q: 〜ですか? | |
| # はいそうです。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Car | |
| _gasoline = 100 | |
| constructor: (@name) -> | |
| run: -> | |
| _gasoline -= 1 | |
| console.log "#{@name}のガソリン:#{_gasoline}" | |
| track = new Car("トラック") | |
| f1 = new Car("F1") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'open-uri' | |
| # 末尾に記述した数値のステータスコードを返してくれるwebサービス | |
| url_root = 'http://ozuma.sakura.ne.jp/httpstatus/' | |
| def open_url(url) | |
| open(url) | |
| end | |
| status_codes = [503, 202, 504] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'open-uri' | |
| # 末尾に記述した数値のステータスコードを返してくれるwebサービス | |
| url = 'http://ozuma.sakura.ne.jp/httpstatus/503' | |
| def open_url(url) | |
| begin | |
| open(url) | |
| rescue OpenURI::HTTPError => e | |
| response = e.io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| begin | |
| raise 'エラーが発生しました' | |
| rescue => e | |
| puts e.message | |
| end | |
| # => エラーが発生しました | |
| # Exceptionだとrescueで型指定しないとcatchできない | |
| begin | |
| raise Exception.new('エラーが発生しちゃった') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'timeout' | |
| require 'open-uri' | |
| TIMEOUT_SECOND = 3 | |
| # 3秒以内にdo~endの処理が完了しないとエラーになる | |
| timeout(TIMEOUT_SECOND) do | |
| puts "task1 done" | |
| end | |
| # => task1 done |