ruby - Data Types compare and return result -
based on argument supplied function. follow through test produce perfect function accounts expectations.
for strings, return length. nil return string 'no value' booleans return boolean numbers return string showing how compares hundred e.g. 67 return 'less 100' 4034 return 'more 100' arrays return 3rd index, or nil if doesn't exist
this same @t.aoukar, less verbose.
def perfect(a) case when string a.size when array a[2] when trueclass, falseclass when nilclass "no value" when numeric #insert code end end
Comments
Post a Comment