Skip to content

Instantly share code, notes, and snippets.

@float1251
Created May 8, 2014 01:27
Show Gist options
  • Save float1251/7132225fa319e85639c8 to your computer and use it in GitHub Desktop.
Save float1251/7132225fa319e85639c8 to your computer and use it in GitHub Desktop.
vimscriptでclassっぽいことをやってみる
" vimscriptでclassっぽく扱う
" dictionaryで頑張る
let s:MyClass = {"foo": "foo"}
function! s:MyClass.print() dict
echo self.foo
endfunction
" instance作成はcopyで代用
function! s:MyClass.new(text) dict
let instance = copy(self)
let instance.foo = a:text
return instance
endfunction
call s:MyClass.print()
let b = s:MyClass.new("Test")
call b.print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment