I have the following simple code
- Code: Select all
"""
Creates a single line "C" style boxed comment
"""
class Program
def main
title = CobraCore.commandLineArgs[1]
if title == String.empty
title = Console.readLine
stars = String(c'*',title.length+6)
spaces = String(c' ',title.length+4)
result = '/[stars]' + Environment.newLine + _
' *[spaces]*' + Environment.newLine + _
' * [title.toUpper] *' + Environment.newLine + _
' *[spaces]*' + Environment.newLine + _
' [stars]/'
print '[result]'
Console.readLine
When compiled the compiler spits out the following error:
error: Incompatible types. Cannot assign value of type String? on the right to String on the left.
While I understand this e.g. Console.readLine outputs a nullable string where my 'title' variable is a non-null string. How can I get the input from the console into a variable. I don’t seem to be able to find an example anywhere that documents this.
Thanks
Greg