Forums

C# casting required to invoke Contains()

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Re: C# casting required to invoke Contains()

Postby jaegs » Wed Sep 26, 2012 5:47 pm

If you want to give the Cobra coder more ways to call .contains, I think the best option is to make extension methods. For example, see http://cobra-language.com/trac/cobra/wiki/StandardLibraryExtensionMethods

Creating another class isn't the best because "Dict" performs the same task as Dictionary.
jaegs
 
Posts: 58

Re: C# casting required to invoke Contains()

Postby jaegs » Wed Sep 26, 2012 8:59 pm

Also I don't think Cobra properly handles test blocks in generic classes. Ex: try testing this -
class X<of T>
test
assert false
jaegs
 
Posts: 58

Re: C# casting required to invoke Contains()

Postby Charles » Wed Sep 26, 2012 9:11 pm

That's true. The workaround that I currently use is to create another class with a test section:
class X<of T>

pass

class XTest

test
assert false
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: C# casting required to invoke Contains()

Postby jaegs » Wed Sep 26, 2012 9:18 pm

OK, here's a ticket
jaegs
 
Posts: 58

Re: C# casting required to invoke Contains()

Postby nerdzero » Wed Sep 26, 2012 9:23 pm

According to MSDN, the Dictionary class already has an extension method for Contains: http://msdn.microsoft.com/en-us/library/xfhwa508.aspx in the System.Linq namespace but I couldn't get it to work. Still, regardless of how it's ultimately implemented, after seeing the syntax, I think I only like .contains(key, value) and am not a fan of .contains(key).
nerdzero
 
Posts: 286
Location: Chicago, IL

Re: C# casting required to invoke Contains()

Postby jaegs » Wed Sep 26, 2012 9:39 pm

Oh, haha, currently only Cobra extensions work in Cobra. C# extensions (ie. LINQ) do not work yet.
jaegs
 
Posts: 58

Previous

Return to Discussion

Who is online

Users browsing this forum: No registered users and 10 guests