Re: rookie code issue
- To: mathgroup at smc.vnet.net
- Subject: [mg130213] Re: rookie code issue
- From: Sseziwa Mukasa <mukasa at gmail.com>
- Date: Thu, 21 Mar 2013 00:55:49 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <20130320082258.D93A969F1@smc.vnet.net>
On Mar 20, 2013, at 4:22 AM, robholman at gmail.com wrote: > Why doesn't the following code return a 2? > > > m = Cos; > Which[m == Sin, 5, m == Cos, 2] Because == doesn't return a boolean value comparing Symbols: (Debug) In[7]:= Cos == Sin (Debug) Out[7]= Cos == Sin Equal is intended for use with numeric quantities, use Same (===) instead: (Debug) In[6]:= Which[m === Sin, 5, m === Cos, 2] (Debug) Out[6]= 2 Regards, Sseziwa
- References:
- rookie code issue
- From: robholman@gmail.com
- rookie code issue