Determinate which method returns true in or operator

supersize

I have:

def user_validation
  first_user_valid? || second_user_valid?
end

and I don't only want to return true/false but also want to return which method returns the true (maybe both?). I do have:

def user_validation
  return true if first_user_valid?
  return true if second_user_valid?
end

so far. But this does not seem very intuitive to me.

Thanks

Uri Agassi

You can return an array of responses:

def user_validation
  [first_user_valid?, second_user_valid?]
end

This way you can know that the first returned true, and the other false...

# => [true, false]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Boolean Method which returns true if brackets match

From Dev

Can the result of as operator be null if the is operator returns true?

From Dev

xUnit Check if method returns true

From Dev

SQL Query - determine which logical operator is true

From Dev

SQL Query - determine which logical operator is true

From Dev

With C++17 only, Is it possible to create a macro which accepts class and method name and returns true if such a method exists in the class?

From Dev

With C++17 only, Is it possible to create a macro which accepts class and method name and returns true if such a method exists in the class?

From Dev

Swift method which returns array

From Dev

Using pipe operator in function which returns Observable

From Dev

Is there a logical operator that returns true if only one of the conditions are true?

From Dev

Determinate when last method has been called in method chaining

From Dev

Determinate when last method has been called in method chaining

From Dev

enum[] is IEnumerable<int> returns true in a generic method

From Dev

TCriticalSection TryEnter Method Always Returns True

From Dev

the method returns false when in fact it is true java

From Dev

Make a for loop wait till a method returns true

From Dev

How can I check if a method returns true?

From Dev

How to test a method which returns a promise in sinon?

From Dev

Can a method be overloaded with another which returns a subclass?

From Dev

How to invoke a method which returns an interface

From Dev

method which reads a file and returns a list of countries

From Dev

Mocking a method which returns Page interface

From Dev

Accessing a property on a method which returns a Model in Laravel

From Dev

return true when first async method returns true

From Java

Default method returns true for a while, and then returns false? (Possible JVM bug)

From Dev

Method sometimes returns true, sometimes returns instance of an object

From Dev

Object returns `false` for both `true` and `false` with the equality operator

From Dev

VS2012 std::function operator bool returns true unexpectedly

From Dev

Date Comparison always returns false no matter which operator used

Related Related

  1. 1

    Boolean Method which returns true if brackets match

  2. 2

    Can the result of as operator be null if the is operator returns true?

  3. 3

    xUnit Check if method returns true

  4. 4

    SQL Query - determine which logical operator is true

  5. 5

    SQL Query - determine which logical operator is true

  6. 6

    With C++17 only, Is it possible to create a macro which accepts class and method name and returns true if such a method exists in the class?

  7. 7

    With C++17 only, Is it possible to create a macro which accepts class and method name and returns true if such a method exists in the class?

  8. 8

    Swift method which returns array

  9. 9

    Using pipe operator in function which returns Observable

  10. 10

    Is there a logical operator that returns true if only one of the conditions are true?

  11. 11

    Determinate when last method has been called in method chaining

  12. 12

    Determinate when last method has been called in method chaining

  13. 13

    enum[] is IEnumerable<int> returns true in a generic method

  14. 14

    TCriticalSection TryEnter Method Always Returns True

  15. 15

    the method returns false when in fact it is true java

  16. 16

    Make a for loop wait till a method returns true

  17. 17

    How can I check if a method returns true?

  18. 18

    How to test a method which returns a promise in sinon?

  19. 19

    Can a method be overloaded with another which returns a subclass?

  20. 20

    How to invoke a method which returns an interface

  21. 21

    method which reads a file and returns a list of countries

  22. 22

    Mocking a method which returns Page interface

  23. 23

    Accessing a property on a method which returns a Model in Laravel

  24. 24

    return true when first async method returns true

  25. 25

    Default method returns true for a while, and then returns false? (Possible JVM bug)

  26. 26

    Method sometimes returns true, sometimes returns instance of an object

  27. 27

    Object returns `false` for both `true` and `false` with the equality operator

  28. 28

    VS2012 std::function operator bool returns true unexpectedly

  29. 29

    Date Comparison always returns false no matter which operator used

HotTag

Archive