Extension Method Error: "static types...parameters"
Posted: Sun Jan 19, 2014 5:55 pm
I get the following error:
With the following code:
I have no idea what I did wrong. Any help would be appreciated.
The code I posted above isn't displayed properly for some reason. I entered the text correctly, but when I click preview I see "colorlib" instead of "-target:lib" and "\" instead of "\\". Huh?
- Code: Select all
fixPath.cobra(12): error: static types cannot be used as parameters
Compilation failed - 1 error, 0 warnings
Not running due to errors above.
With the following code:
"""Extends Path to fix the slashes of a path"""
@platform clr
@args colorlib -color
namespace FixPath
"""Extends Path to fix the slashes of a path"""
extend Path
"""Extend with method to fix the slashes of a path"""
def fix(path as String) as String is shared
"""
Fix the slashes of the given path so it works on the current platform
"""
ensure result.length == path.length
test
assert Path.fix("") == ""
assert Path.fix(" ") == " "
assert Path.fix("File Name") == "File Name"
assert Path.fix("Path/Name") == Path.combine("Path", "Name")
assert Path.fix("Path\Name") == Path.combine("Path", "Name")
assert Path.fix("A\Path/File") == Path.combine("A", "Path", "File")
body
return .combine(path.split("/", "\"))
I have no idea what I did wrong. Any help would be appreciated.
The code I posted above isn't displayed properly for some reason. I entered the text correctly, but when I click preview I see "colorlib" instead of "-target:lib" and "\" instead of "\\". Huh?