Skip to content

Instantly share code, notes, and snippets.

View taisyo7333's full-sized avatar

Daisuke Inoue taisyo7333

View GitHub Profile
@taisyo7333
taisyo7333 / Code3-166.rb
Created January 24, 2016 10:30
Ruby throw - catch
# encoding: utf-8
def bar
catch(:calc) do
throw :calc , 100
end
end
p bar
# => 100
@taisyo7333
taisyo7333 / Code4-3.rb
Created January 25, 2016 11:43
Ruby Class式評価時にクラス定義の内部が評価される
# encoding: SJIS
p 1
class Hoge
p 2
end
p 3
@taisyo7333
taisyo7333 / Code4-7.rb
Created January 25, 2016 13:52
Ruby Class
# encoding: SJIS
class Foo
def initialize(a)
@a = a
end
def method1
@a
end
end
@taisyo7333
taisyo7333 / Code4-10.rb
Created January 25, 2016 13:58
Ruby Class methods : alias , undef
# encoding: SJIS
class Hoge
def huga1; end
def huga2; end
alias :huga3 :huga1
undef :huga2
end
p Hoge.instance_methods(false)
@taisyo7333
taisyo7333 / Code4-11.rb
Created January 25, 2016 14:02
Ruby Class : override instance method.
# encoding: SJIS
class Hoge
def method_missing(m,*args)
p "called:" + m.to_s
super # call original exception
end
end
Hoge.new.no_method
@taisyo7333
taisyo7333 / ruby_exam_001.rb
Created February 22, 2016 00:02
Ruby 悩んだこと # 1
true || y = 1
p y # => nil
@taisyo7333
taisyo7333 / ruby_exam_002_File_join.rb
Last active February 22, 2016 23:22
Ruby 悩んだこと #2
File.join("/","g") # => /g
File.join("a","g") # => a/g
File.join("","g") # => /g
File.join("","g","") # => /g/
File.join("","","g","") # => /g/
@taisyo7333
taisyo7333 / ruby_memo.txt
Created February 24, 2016 00:07
ruby memo
Ruby 既存ファイルを開く時のモードについて
"w" : 書き込みモード:既存ファイルの場合は、ファイルの内容を空にする。
"w+": 読み書きモード:既存ファイルの場合は、ファイルの内容を空にする。
"r+": 読み書きモード:ファイルの読み書き位置が戦闘になる。
"a" : 追記モード  :常にファイルの末尾に追加
"a+": 読み書きモード:ファイルの読み込み位置は先頭。書き込み位置は常に末尾。
@taisyo7333
taisyo7333 / Memo
Created February 24, 2016 02:39
JavScript 調べたこと。
調べた英単語
hoist [verb]
1. to raise (something) especially by using ropes or machinery
ロープなどを使って持ち上げる。
2. drink (informal)
3. to take a shot , (basketball , informal)
使用例) https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes
An important difference between function declarations and class declarations is that function declarations are hoisted and class declarations are not.
https://github.com/goatslacker/alt/issues/283
http://egorsmirnov.me/2015/08/16/react-and-es6-part3.html