How to get all values from a variable made of value separated by a pipe ( | )?

Nico

I have a variable of type UIRectEdge that I initiated like that:

var edges: UIRectEdge = .Right | .Left

Later on, I need to know what does this variable contain. How can I run through it?

Fonix

If you want to just find out if the variable contains a certain component you can go like so:

    var edges: UIRectEdge = .Right | .Left | .Top

    if(edges & UIRectEdge.Right == UIRectEdge.Right){
        println("right")
    }

    if(edges & UIRectEdge.Left == UIRectEdge.Left){
        println("left")
    }

    if(edges & (UIRectEdge.Left | UIRectEdge.Top) == (UIRectEdge.Left | UIRectEdge.Top)){
        println("left and top")
    }

Here's why this works:

Say for instance left is 00100 (in binary), and right is 01000. Combining them with the OR operator (the pipe) makes 01100.

Then, using the AND operator 01100(combined) & 01000(right) will find where both those binary numbers are both 1, and make that bit a 1, which would be the same as the original number (right):

01100 (.Right | .Left)   & 
01000   (.Right) =
01000   (.Right)

Note these are the binary operators & and |; not the logical && and ||.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Get values from the pipe separated file

From Dev

How to get values from JtextField that was made in constructor

From Dev

Get values separated by pipe ("|") in C#

From Dev

Get values from the key-value pairs in a comma separated string

From Dev

How to get values from a string array and assign them to a multi line textbox where all the values are separated with a new line in VB.net

From Dev

How to get values from a string array and assign them to a multi line textbox where all the values are separated with a new line in VB.net

From Dev

How to use sed to modify the value in a specific column in a file with pipe-separated values

From Dev

How to retrieve a value from a list of keys/values separated by pipes?

From Dev

How do I get multiple comma separated values from URL

From Dev

Get values from Key/Value variable in javascript

From Dev

How to get all values from all textfields

From Dev

How to get all values from all textfields

From Dev

How to send variable value to pipe while hiding it from the process list?

From Dev

How to get all the distinct data from the columns pipe delimited

From Dev

Get dictionary value from variable name constructed from variable values

From Dev

How to get text value from div with class name separated?

From Dev

Extracting a string value from a pipe-separated string in a table column

From Dev

How to parse pipe-separated Attribute=Values pairs?

From Dev

Multiple values separated by a pipe in Java

From Dev

How to concatenate all map key-values into a string, using streams, with replacements made on each value?

From Dev

How to add all comma separated values in XSLT

From Dev

How to get all values from table

From Dev

How to get all values from Jlist?

From Dev

How to get all values from a list?

From Dev

How to get all values from multiple options

From Dev

How to get all the values from a FilteringSelect in dojo?

From Dev

How to get all values from same column?

From Dev

How to get values in variable from jsonObject?

From Dev

How to get values in variable from jsonObject?

Related Related

  1. 1

    Get values from the pipe separated file

  2. 2

    How to get values from JtextField that was made in constructor

  3. 3

    Get values separated by pipe ("|") in C#

  4. 4

    Get values from the key-value pairs in a comma separated string

  5. 5

    How to get values from a string array and assign them to a multi line textbox where all the values are separated with a new line in VB.net

  6. 6

    How to get values from a string array and assign them to a multi line textbox where all the values are separated with a new line in VB.net

  7. 7

    How to use sed to modify the value in a specific column in a file with pipe-separated values

  8. 8

    How to retrieve a value from a list of keys/values separated by pipes?

  9. 9

    How do I get multiple comma separated values from URL

  10. 10

    Get values from Key/Value variable in javascript

  11. 11

    How to get all values from all textfields

  12. 12

    How to get all values from all textfields

  13. 13

    How to send variable value to pipe while hiding it from the process list?

  14. 14

    How to get all the distinct data from the columns pipe delimited

  15. 15

    Get dictionary value from variable name constructed from variable values

  16. 16

    How to get text value from div with class name separated?

  17. 17

    Extracting a string value from a pipe-separated string in a table column

  18. 18

    How to parse pipe-separated Attribute=Values pairs?

  19. 19

    Multiple values separated by a pipe in Java

  20. 20

    How to concatenate all map key-values into a string, using streams, with replacements made on each value?

  21. 21

    How to add all comma separated values in XSLT

  22. 22

    How to get all values from table

  23. 23

    How to get all values from Jlist?

  24. 24

    How to get all values from a list?

  25. 25

    How to get all values from multiple options

  26. 26

    How to get all the values from a FilteringSelect in dojo?

  27. 27

    How to get all values from same column?

  28. 28

    How to get values in variable from jsonObject?

  29. 29

    How to get values in variable from jsonObject?

HotTag

Archive