0

I have a very simple question, but could not figure it out by Google search, please help.

I want to produce this string '\u0000' (note the simple quote marks surrounding it!) using the following simple Xtend method containing a template expression:

def String makeDefaultChar()
{
   ''''\u0000''''
}

However, this is not accepted as proper syntax (probably because of the four ''''. Is there an escape character for this use case or what is the right syntax?

Thank you in advance!

P.S.

Of course I could use plain Java string like this "'\\u0000'" to achieve the same, but I want to use an Xtend template expression.

My Xtend version is: 2.9.1.v201512180746

Software Craftsman
  • 2,999
  • 2
  • 31
  • 47

2 Answers2

1

There is no "escaping" in template expressions, so you have to use the workaround you mentioned:

'''«"'\\u0000'"»'''

or

'''«"'"»\u0000«"'"»'''

Related discussion: https://groups.google.com/forum/#!topic/xtend-lang/bVZ0nKmQGAI

snorbi
  • 2,590
  • 26
  • 36
1

Single quotes are allowed within Xtend templates as long as they do not occur at the beginning or the end of the template. So a simple workaround is to add an empty expression before/after the single quote:

'''«»'\u0000'«»'''
Elie Richa
  • 51
  • 4