Search Unity

combining evaluators

Discussion in 'Scripting' started by hai_ok, Sep 19, 2009.

  1. hai_ok

    hai_ok

    Joined:
    Jun 20, 2007
    Posts:
    193
    I can do this:

    Code (csharp):
    1. if ("abc" in value){
    2.   if (script.othervalue){
    3.     doathing();
    4.   }else{
    5.     script.doanotherthing();
    6.   }
    7. }
    but I can not do this:

    Code (csharp):
    1. if ("abc" in value  script.othervalue){
    2.   doathing();
    3. }else{
    4.   script.doanotherthing();
    5. }
    and this doesn't work either:

    Code (csharp):
    1. if ("abc" in value  script.othervalue != 0){
    2.   doathing();
    3. }else{
    4.   script.doanotherthing();
    5. }
    all of this is pseudocode btw, in case you think I'm compelty abstracting everything, lol.

    this is all being evaluated inside of this context (in case it has any baring):

    Code (csharp):
    1. Switch (variable){
    2.   case "value":
    3.     /*stuff from above goes here*/
    4.   break;
    5.   ...
    6. }
    any reason this doesn't work?

    error being returned is:

    Code (csharp):
    1. MissingMethodException: Method not found: 'System.String.op_Member'.
    2. Boo.Lang.Runtime.MethodDispatcherFactory.ProduceExtensionDispatcher ()
    3. Boo.Lang.Runtime.MethodDispatcherFactory.Create ()
    4. Boo.Lang.Runtime.RuntimeServices.DoCreateMethodDispatcher (System.Object target, System.Type targetType, System.String name, System.Object[] args) [0x00000]
    5. Boo.Lang.Runtime.RuntimeServices.CreateMethodDispatcher (System.Object target, System.String name, System.Object[] args) [0x00000]
    6. Boo.Lang.Runtime.RuntimeServices+<>c__DisplayClass1.<Invoke>b__0 ()
    7. Boo.Lang.Runtime.DispatcherCache.Get (Boo.Lang.Runtime.DispatcherKey key, Boo.Lang.Runtime.DispatcherFactory factory)
    8. Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Type[] cacheKeyTypes, System.Object[] args, Boo.Lang.Runtime.DispatcherFactory factory) [0x00000]
    9. Boo.Lang.Runtime.RuntimeServices.Dispatch (System.Object target, System.String cacheKeyName, System.Object[] args, Boo.Lang.Runtime.DispatcherFactory factory) [0x00000]
    10. Boo.Lang.Runtime.RuntimeServices.Invoke (System.Object target, System.String name, System.Object[] args) [0x00000]
    11. Boo.Lang.Runtime.RuntimeServices.InvokeBinaryOperator (System.String operatorName, System.Object lhs, System.Object rhs)
    12.  
    and I JavaScript, I do not boo.
     
  2. rozgo

    rozgo

    Joined:
    Feb 7, 2008
    Posts:
    158
    lol :)

    maybe the 'in' keyword is confusing the compiler

    try a container lookup function like Contains() or IndexOf()

    the 'in' keyword doesn't do a value lookup in containers in all languages, maybe thats the case for javascript
     
  3. hai_ok

    hai_ok

    Joined:
    Jun 20, 2007
    Posts:
    193
    Thanks so much rozgo!
    Guess I was looking for a flaw in my logic, but what you said makes sense.
    I'll try that.

    Thanks again!