Grasshopper

algorithmic modeling for Rhino

Function error: Operator < not defined for bool and double

Hi, 

Can anyone lend some support.. I am trying to dispatch out values that are greater than one variable and less than another. when i input the function y<x<z, i get the error: Operator < not defined for bool and double. Any ideas or alternate ways to do this? 

 

Thanks!

Joe

Views: 2143

Attachments:

Replies to This Discussion

y<x<z is evaluated in two steps. This becomes more obvious once we add precedence brackets to show this:


(y < x) < z


The above results in exactly the same code. So first y and x are compared and the result is a boolean. y is either smaller than x or it isn't, so:


1.   (y < x) = True

2.   (y < x) = False


We can now replace the evaluation with the result, giving us:


1.  True < z

2.  False < z


This is a not a valid comparison, as Boolean values are not smaller than numbers in any meaningful way.


To do what you want you'll need to perform both comparisons individually, then combine the results using a Boolean Gate:


(y<x) And (x<z)


--

David Rutten

david@mcneel.com

Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service