Last active
August 29, 2015 14:19
-
-
Save studio3104/d66e335d435e30f36eda to your computer and use it in GitHub Desktop.
インスタンス変数があったらそれ返してなかったらなんか処理してインスタンス変数に突っ込んでから返すって処理
This file contains 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 Hoge: | |
def hage(self): | |
if not '_hage' in self.__dict__.keys(): | |
self._hage = 'hage' | |
return self._hage | |
hoge = Hoge() | |
print hoge.hage() |
This file contains 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 Hoge | |
def hage | |
@hage ||= 'hage' | |
end | |
end | |
hoge = Hoge.new | |
p hoge.hage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment