J
Josselin
I know I can write it the 'ugly common way' (loop)
but I'd like to see how it can be done the Ruby way ... (I am a newbie...)
here is an array
roles = [ "a", "b", "c", "d", "e" ]
Depending upon a variable 'user.role',
I would like to suppress all elements in the array , less or equal to
this variable
ex :
user.role = "a" #=> roles = ["b", "c", "d", "e" ] "a" deleted
user.role = "b" #=> roles = ["c", "d", "e" ] "a", "b" deleted
user.role = "c" #=> roles = [ "d", "e" ] "a", "b", "c" deleted
user.role = "d" #=> roles = [ "e" ] "a", "b", "c", "d" deleted
user.role = "e" # do nothing
thanks for your tips
Joss
(I am on my way to buy the Ruby Recipes PDF Cookbook...)
but I'd like to see how it can be done the Ruby way ... (I am a newbie...)
here is an array
roles = [ "a", "b", "c", "d", "e" ]
Depending upon a variable 'user.role',
I would like to suppress all elements in the array , less or equal to
this variable
ex :
user.role = "a" #=> roles = ["b", "c", "d", "e" ] "a" deleted
user.role = "b" #=> roles = ["c", "d", "e" ] "a", "b" deleted
user.role = "c" #=> roles = [ "d", "e" ] "a", "b", "c" deleted
user.role = "d" #=> roles = [ "e" ] "a", "b", "c", "d" deleted
user.role = "e" # do nothing
thanks for your tips
Joss
(I am on my way to buy the Ruby Recipes PDF Cookbook...)