What's the difference between 'Array<_>' & 'Array' - xcode

I'm getting this error when trying to build the app:
<unknown>:0: error: cannot assign value of type 'Array<_>' to type 'Array'
but Xcode is not indicating a specific line or class for the failure.
If I could understand the difference between
Array<_>
&
Array
it may help me locate the issue.

When you app is crashing, than you can turn on All Exceptions for Debug breakpoint. This should stop on the line where the crash appears.
You find this in Xcode on the Left Panel-> BreakPoint Navigator.
Than press the + in the bottome left corner and Add Exception Breakpoint.
It looks like that you overwrite an array with an array that has a specific value definition. Good Luck :)

A generic argument clause is enclosed in angle brackets ( < > )
< generic argument list >
You can replace a type parameter with a type argument that is itself a specialized version of a generic type.For example, you can replace the type parameter T in Array < T > with a specialized version of an array, Array< Int > , Array< String >, to form an array whose elements are themselves array of integers / Strings

Regarding xour code Snippet the fix is:
u should define it with the right value ... userTweetsArray : [String] = String . or remove the : [String] because setting the value defines already the object and type :)

I don't like answering my own questions but for the sake of closure
I had this line of code
var userTweetsArray : Array = [String]()
I never actually used it. Once I removed that line the error had gone.
The error was caused by assigning an array of a type in this case String to an Array of no type.
So difference is Array<_> is an array of a type and Array is not.

Related

How to Deserialize in Boo language

Why does the second line give an error?
items = serializer.DeserializeObject(json)
value = items ["key"]
Error: Type 'object' does not support slicing. (BCE0048)
I tried various ways to indicate that "items" is a dictionary, to no avail.
Solution:
items as Dictionary [of string, object] = serializer.DeserializeObject(json)

Array concatenation in IBM Filenet P8 Expression Builder?

In the Expression Builder for the Workplace Process Designer, I have an attachment variable of type String[] (array of strings). I'd like to add some elements to it using the Expression Builder, but I can't work out the syntax. Has anyone done this? Is it even possible to add elements to an existing array in Expression Builder?
The arraytostring solution only works if there is only one element the array.
Assign the additional value with the following expression:
stringarray[elementcount(stringarray) + 1] = value
The expected 'array out of bound exception' and the resizing of the array is handled during the assignment.
I originally thought that it is not possible that we had to resort to have a custom java component to do the job, however I had run a small experiment that should serve as a workaround for your case.
Suppose you have String[] arrayType={"string1, string2"}, you can use the following expression as a value for your updated array:
{(arraytostring(arrayType, " ", " ,", ","))+"string3"}
What I did was that,
First, I used arraytostring function to convert the array to a string separated by comma with a comma left at the end. My output is similar to string1,string2,
Second, I appended the string that I want to add to the end of the string, so that my output is string1,string2,string3
Lastly, I assigned the value above to my array, using the array expression format {}, so my final evaluated string is {string1,string2,string3}
For more information about array functions, please follow the link below:
https://www.ibm.com/support/knowledgecenter/SSNW2F_5.2.1/com.ibm.p8.pe.user.doc/bpfe003.htm
I had a case like this, here is what I did:
I get the array from the attachment using the CE-Operation and store
in an array property on the workflow
Then I used the following to
{(arraytostring(workflowArray, " ", " ,", ","))+workflowStringProp}
using the CE-Operation again to set the array in the attachment with
the workflowArray.

Passing Field Symbol value to Return parameter of method

I have the below code which uses a method. When I try to assign the Field Symbol value [Type ANY] to the return parameter RO_TAB [Type Ref to Data], I am getting an error message OBJECTS_MOVE_NOT SUPPORTED [Conversion of type "l" to type "g" not supported.].
The issue is happening after a BW system upgrade along with which we also moved to ABAP objects. The code executes perfectly in the older version of ABAP.
The dump occurs in the below line:
RO_TAB = <lf_storage>.
I have no idea why.
method GET_LU_STORAGE_FOR_ODS.
* IMPORTS
* IF_ODS TYPE RSODSTECH
* IF_ODS_TABLE_TYPE TYPE ZODS_TAB_TYPE
* RETURNS
* RO_TAB TYPE REF TO DATA
FIELD-SYMBOLS:
<lf_storage> TYPE ANY.
DATA:
lf_index TYPE SY-TABIX,
lf_sindex TYPE STRING,
lf_name TYPE STRING.
lf_index = GET_LU_STORAGE_INDEX(
IF_ODS = IF_ODS
IF_ODS_TABLE_TYPE = IF_ODS_TABLE_TYPE ).
lf_sindex = lf_index.
CONCATENATE
'MO_LU_DATA_'
lf_sindex
INTO lf_name.
ASSIGN lf_name TO <lf_storage>.
RO_TAB = <lf_storage>.
endmethod.
You need to create a data object first, using the CREATE DATA statement. Then you can ASSIGN a field symbol to work with the dynamically created data object. There's an example in the online manual. A field symbol is not a reference, it simply places the variable assigned to it in its position. You're effectively trying to move a string (which is what lf_name is) to a reference variable, and that won't work.
You cannot assign a variable of type STRING to a variable of type REF TO DATA.
The following code snippet shows how it should be done.
DATA: lf_name TYPE string.
DATA: lo_tab TYPE REF TO DATA.
FIELD-SYMBOLS: <lf_name> TYPE string.
lf_name = 'test'.
GET REFERENCE OF lf_name INTO lo_tab.
*lf_name = lo_tab. "this is not allowed
ASSIGN lo_tab->* TO <lf_name>.
So in your case it would be sufficient to define a field symbol.
FIELD-SYMBOLS: <lf_name> TYPE STRING.
then assign the contents referenced by RO_TAB to this field symbol.
ASSIGN ro_tab->* TO <lf_name>.
and finally do the concatenation.
CONCATENATE
'MO_LU_DATA_'
lf_index
INTO <lf_name>.
That's all! No further assignments should be required.
How about just this?
lf_sindex = lf_index.
CONCATENATE
'MO_LU_DATA_'
lf_sindex
INTO RO_TAB.

Matlab:figure error

I'm having a problem with set function in MatLab gui I'm getting this error :
Invalid handle object.
there is my code:
[value index] = min( CostFunction(params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, y, lambda));
set(handles.cfwoText,????,value);
Value returned from [value index]is type double ex:1.4563e-011,and I want to show it on EditText called cfwoText,but i dont know what type should I write in ?
I believe a simple google search will provide an answer.
In addition, in GUIDE you can write click your Edit Text and choose Property Inspector. You will see all the properties.
Having said that, what you are looking for is
set(handles.cfwoText,'String',num2str(value));
Note that num2str is required since value is double and the text is string.

Is Nothing comparison gives type mismatch

I am trying to check if the 'Listivew.Tag property is nothing'.
I used to do the 'Is Nothing' check universally for all scenarios as first check to avoid errors
Can someone explain how to do it in VB 6?
If Not .lvwLocation.Tag Is Nothing Then
'COMPANY
str = str & IIf(Len(.lvwLocation.Tag) > 0, " and u.location_id in " & .lvwLocation.Tag, "")
End If
Gives error 'type-mismatch'
Nothing is a valid value for Object variables, and Is is the way to compare object pointers.
But a VB6 control's Tag property is a String, and VB6's String type is not an Object; it's a primitive type. That means a String variable can't be assigned Nothing -- its emptiest possible value is the empty string. (And an Object variable can't be assigned a String value.) For strings just use the same equality/inequality/comparision operators that you use for other primitive (numeric/boolean/date) types:
If .lvwLocation.Tag <> "" Then ...
In VB6 it appears that using Is Nothing to compare Objects works, Every other data type that I tried did not. In .Net Nothing represents the default value of any data type and will work like you expect.
Dim test as Object
If Not test Is Nothing Then
/////
End If
Since it appears the data type of th Tag property in VB6 is a string. I would use something like:
If .lvwLocation.Tag <> "" Then
/////
End If

Resources