Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Question about: Low-Bit Operators (and some...)

Hello there fellows.
Ive been a while in scripting now. But there are still some operators wich I don;t use, thus don't understand. It is about:
Code:
>> (transfer bits to the right)
<< (transfer bits to the left)
>>>
<<<
<=> (compares right?)

Oh.. well. What are they used for?

(and if you got spare time. I always mess up with blocks | each. example:

.each {block|each} or .sub!(regexpcode) {things to do?})
 
first, >>> and <<< doesn't exist (unless I'm mistaken)

about << and >>, it depends with what object you use them

array << value is similar to array.push(value)

<< is also used to reformate dates

you can also use it to store values in IO objects.

works also with strings : string = "hello"
string << " world"

p string # "hello world"

and for <=> generally means 'compare' but again, it all depends with what objects you use it.

[1, 2, 3] <=> [2, 6, 7] # [2]

Numberic <=> Numeric # returns -1, 0 or 1 depending if the number is greater of smaller.

I suggest you look at reference book to know more since there'd be a lot to list
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top