Created
December 3, 2012 02:01
-
-
Save holysugar/4192128 to your computer and use it in GitHub Desktop.
後置 while にする?
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
def generate_name | |
begin | |
name = Digit.generate(6) | |
end while Image.exists?(name: name) | |
name | |
end | |
def generate_name | |
loop do | |
name = Digit.generate(6) | |
return name unless Image.exists?(name: name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment