Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created July 3, 2015 08:08
Show Gist options
  • Save anonymous/ac5e6f0209857bbcfd23 to your computer and use it in GitHub Desktop.
Save anonymous/ac5e6f0209857bbcfd23 to your computer and use it in GitHub Desktop.
def generate_resources(x, y, z)
raise Exception.new("x can not be lower then 1") unless x > 0
rescue => e
x = 1
@baweaver
Copy link

baweaver commented Jul 3, 2015

x = if x > 0 then x else 1 end
# or the ternary
x = x > 0 ? x : 1

@tvb
Copy link

tvb commented Jul 3, 2015

 def generate_resources(num_instances = 1, instance_type = 't1.small', cidr_ip = '127.0.0.1')
    num_instances = 1 unless num_instances > 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment