User Tools

Site Tools


assign_no_returnvalue

Assign cannot have a return value

VO unfortunately permits to return a value from an assign. Since this is not permitted in .NET, the X# compiler will return an error of

Warning XS9032 This entity type cannot return a value. Return value ignored.

The following code, perfectly valid in VO, will throw this warning in X#:

class MyClass
  protect _cMyVar as string
 
assign MyVar( cMyVar ) class MyClass
  _cMyVar := cMyVar
 
  return _cMyVar

It is recommended to type the access/assign pairs in VO, like this sample:

class MyClass
  protect _cMyVar as string
 
  declare assign MyVar  
 
assign MyVar( cMyVar as string ) as void pascal class MyClass
  _cMyVar := cMyVar
 
  return

In this manner the compiler will you notify when you anywhere in your code have used the return value of the assign statement. (other than giving you faster and more stable code)

assign_no_returnvalue.txt · Last modified: 2018/06/09 10:48 by wolfgangriedmann