Here is a simple method to compare two arrays using Ruby, few examples:
> [1,2,3] <=> [1,2,3]
=> 0
> [1,2,3] <=> [2,2,3]
=> -1
> [1,2,3] <=> [3,2,3]
=> -1
> [1,2,3] <=> [1,3,3]
=> -1
> [1,2,3] <=> [1,1,3]
=> 1
By use of Terinary Operator (<=>), we can acheive the simple method to compare two arrays of comparison.
Hope this will help for someone or me in future!!!
Subscribe to:
Post Comments (Atom)
1 comment:
It may be difficult for some companies to adjust to the fact that they will have to spend a higher percentage of their budget on AWS, but the long-term benefits cannot be underestimated. For more interesting information on cloud cost optimization find out here.
Post a Comment