Skip to content

Instantly share code, notes, and snippets.

@holysugar
Created December 3, 2012 02:01
Show Gist options
  • Save holysugar/4192128 to your computer and use it in GitHub Desktop.
Save holysugar/4192128 to your computer and use it in GitHub Desktop.
後置 while にする?
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