Ring Documentation Walkthrough #4 – Operators

At this post i will talk about The Operators, let’s start.

Arithmetic Operators:

  • Add operator +
    • x  + y
  • Subtract operator –
    • x – y
  • Multiply operator *
    • x * y
  • Divide operator /
    • x / y
  • Mod operator %
    • x % y
  • Increment operator ++
    • x++ , y++
  • Decrement operator —
    • x– , y–

The arithmetic operators are the same as any other language so i won’t put examples on them.

Relational Operators:

  • Equal operator =
  • Not Equal operator !=
  • Greater than > & Less than <
  • Greater than or equal >= & Less than or equal <=

Logical Operators:

Assume you have x = True & y = False.

  • Logical AND : and
    • x and y –> FALSE
  • Logical OR : or
    • x or y –> True
  • Logical Not : not
    • not x –> FALSE, not y –> TRUE

Bitwise Operators:

  • Binary AND : &
  • Binary OR : |
  • Binary XOR : ^
  • Binary Ones Complement : ~
  • Binary Left Shift : <<
  • Binary Right Shift : >>

Assignment Operators:

  • Assignment =
  • Add & Assignment +=
  • Subtract & Assignment -=
  • Multiply & Assignment *=
  • Divide & Assignment /=
  • Mod & Assignment %=
  • Left shift & Assignment <<=
  • Right shift & Assignment >>=
  • Bitwise & Assignment &=
  • Bitwise OR & Assignment !=
  • Bitwise XOR & Assignment ^=

Misc Operators:

  • :literal – using : before an identifier means literal
  • Star:End – create a list contains item from ‘start’ to ‘end’
  • [list item] – this defines list items
  • list[index] – access a list item
  • obj.name – as usual using to DOT operator to access object attributes/methods
  • obj {…} – execute statements with direct access to object attributes and methods
  • func (parameter,….) – call a function with parameters separated by comma

Operators Precedence:

operators from higher precedence (Evaluated first) to lower precedence.

  • . [] () {}
  • – ~ :Literal [list items]
  • ++ —
  • Start:End
  • * / %
  • + –
  • << >>
  • &
  • | ^
  • <> <= >=
  • = !=
  • not
  • and or
  • =, +=, -=, *=, /=, %=, >>=, <<=, &=, ^=, |=

amrESSAM.

Advertisements
Ring Documentation Walkthrough #4 – Operators

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s