78186

Bitwise OR returns boolean when one of operands is nil

Why does bitwise OR return a boolean here. Of all the operators, I would least expect that from bitwise ones.

nil | 5 # => true nil | 0 # => true nil | true # => true nil | false # => false nil | nil # => false

Answer1:

Found an answer in the same topic :)

Turns out that NilClass#| is overridden:

false | obj → true or false nil | obj → true or false Or—Returns false if obj is nil or false; true otherwise.

Recommend

  • OpenCV detect square with difficult background
  • Bit not operation in PHP(or any other language probably)
  • Help translating Reflector deconstruction into compilable code
  • SQL Server: +(unary) operator on non-numeric Strings
  • Wrap C++ function using Boost Reflect or another C++ reflection library
  • Ruby 1.8.6 Array#uniq not removing duplicate hashes
  • How to remove a SwiftyJSON element?
  • Simulate click Geckofx vb,net
  • Eloquent paginate function in Slim 3 project using twig
  • How can I extract results of aggregate queries in slick?
  • OOP Javascript - Is “get property” method necessary?
  • Groovy: Unexpected token “:”
  • How to have background script and something similar to a default popup?
  • d3 v4 drag and drop with TypeScript
  • Row Count Is Returning the incorrect number using RaptureXML
  • PHP - How to update data to MySQL when click a radio button
  • jQuery show() function is not executed in Safari if submit handler returns true
  • RectangularRangeIndicator format like triangular using dojo
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • Obtain ObjectIdHex value from mgo query
  • Possible to stop flickering java tooltip in heavyweight mode?
  • How to model a transition system with SPIN
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Cant find why the layout is getting smaller
  • How to stop GridView from loading again when I press back button?
  • sending mail using smtp is too slow
  • MATLAB: Piecewise function in curve fitting toolbox using fittype
  • Is there any way to bind data to data.frame by some index?
  • Django query for large number of relationships
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • How can I use `wmic` in a Windows PE script?
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • How to push additional view controllers onto NavigationController but keep the TabBar?