Inverting layerMask causes error

Hi,

I want to get one layer to be ignored by a raycast. There is a nice workaround in the documentation: Unity - Manual: Layers

It works fine, but when it comes to inverting the layerMask, I am getting this error:
Operator '~' cannot be used with an expression of type 'UnityEngine.LayerMask'.

Here is my code:

    var layerMask : LayerMask = 1 << LayerMask.NameToLayer ("Unclickable");
	layerMask = ~layerMask;
  	var FinalMask:LayerMask  = (layerMask.value);
  	    
	ray = camActive.ScreenPointToRay(Input.mousePosition);
       
	Physics.Raycast (ray, hit, 100, FinalMask.value);

Any idea, why the documentations example doesn’t run?

operator ~ can be applied to int types, but not to enums. so use this:

var layerMask : int = 1 << LayerMask.NameToLayer ("Unclickable");

also found this solution:

var layerMask : LayerMask = ~(1 << LayerMask.NameToLayer ("Unclickable"));