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.
Forums
C# casting required to invoke Contains()
16 posts
• Page 2 of 2 • 1, 2
Re: C# casting required to invoke Contains()
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()
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()
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()
Oh, haha, currently only Cobra extensions work in Cobra. C# extensions (ie. LINQ) do not work yet.
- jaegs
- Posts: 58
16 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 7 guests