What does %w(array) mean?
%w(foo bar)
is a shortcut for ["foo", "bar"]
. Meaning it's a notation to write an array of strings separated by spaces instead of commas and without quotes around them. You can find a list of ways of writing literals in zenspider's quickref.
what does ArrayT? mean
return arrayOfNulls<MyData>(0)
What this line means:
arrayOfNulls
Return an array of N elements (zero in your case), but fill it with null<MyData>
The Data-Type isMyData
, which is NOT nullable
So you create an array with null
values (even if the size is zero) but the DataType is not nullable:
Two solutions:
// zero elements in the array but not nullable
fun getDataArray(): Array<MyData> {
return arrayOf()
}
// array with nullable data-type
fun getDataArray(): Array<MyData?> {
return arrayOfNulls<MyData?>(0)
}
What does *array[] means?
*array[]
means array of pointers, in your example:
char *somarray[] = {"Hello"};
somarray[]
is array of char*
. this array size is one and contains address to on string "Hello"
like:
somarray[0] -----> "Hello"
somarray
means address of first element in array.
&somarray
means array address
*somarray
means value of first element
Suppose address of "Hello"
string is for example 201, and array somaaray
at 423
address, then it looks like:
+----+----+----+---+---+----+----+----+---+----+
| `H`| 'e'|'l'|'l'|'o'| '\0'|
+----+----+----+---+---+----+----+----+---+---+----+
201 202 203 204 205 206 207 208 209 210 2
^
|
+----+----+
| 201 |
+----+----+
423
somarray
and:
somarray
gives 423
&somarray
gives 423
*somarray
gives 201
Point to be notice somarray
and &somarray
gives same value but semantically both are different. One is address of first element other is address of array. read this answer.
What does ... in an array mean?
Usually, this happens when there are too many items to be displayed .The ... means that there are more elements that are not shown right now.The only items that are shown are starting and ending items.This doesn't mean that you cannot access these items.
What does string array[] = ; mean and why does it work?
This is incorrect code; it is a bug in your compiler (possibly gcc/g++?) to accept it.
clang gives the following error (link):
a.cpp:5:17: error: array initializer must be an initializer list
std::string array[] = "";
^
1 error generated.
Visual C++ agrees (link):
testvc.cpp(2) : error C3074: an array can only be initialized with an initializer-list
The relevant clause in the standard is 8.5p17:
[...]
— If the destination type is an array of characters, an array of char16_t, an array of char32_t, or an array of wchar_t, and the initializer is a string literal, see 8.5.2.
[...]
— Otherwise, if the destination type is an array, the program is ill-formed.
[...]
Submitted to gcc as a bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60009
What does (array) $variable mean in php
When you cast a string to an array in PHP it becomes an array with the string pushed to it.
Example:
$test = "This is a string!";
print_r((array) $test);
Output:
Array
(
[0] => This is a string!
)
That said I find the code strange, I don't see the need for the loop, it could just be:
$key = "upload_8_fid_aids.tmp";
public function to_key($key) {
$s = $this->table; //$s = kv
$s .= '-' . $this->primarykey[0] . '-' . $key;
return $s;
}
what does !Array.string= mean in angular?
The operators are from Google Closure's Type Expressions.
!
identifies the type as "Non-nullable."<...>
identifies the type(s) of an object/collection's contents.=
identifies the parameter as "Optional."
So, in the case of angular.module()
:
- No argument has to be given for
requires
. - When it is given, it cannot be
null
and must be anArray
containing only string values.
angular.module('Foo'); // valid arguments
angular.module('Foo', null); // not valid
angular.module('Foo', ['Bar']); // valid
angular.module('Foo', [false]); // not valid
angular.module('Foo', function(){}); // valid
Why do you use %w[] in rails?
This is the most efficient way to define array of strings, because you don't have to use quotes and commas.
%w(abc def xyz)
Instead of
['abc', 'def', 'xyz']
Related Topics
How to Remove Rvm (Ruby Version Manager) from My System
Look Up All Descendants of a Class in Ruby
How to Set Tls Context Options in Ruby (Like Openssl::Ssl::Ssl_Op_No_Sslv2)
The 'Json' Native Gem Requires Installed Build Tools
Checking If a Variable Is Defined
Sort Hash by Key, Return Hash in Ruby
How to Have Ruby Logger Log Output to Stdout as Well as File
How to Convert a Unix Timestamp (Seconds Since Epoch) to Ruby Datetime
Accessing Elements of Nested Hashes in Ruby
Understanding the Rails Authenticity Token
What Does the "===" Operator Do in Ruby
When to Use Symbols Instead of Strings in Ruby
What Does a Double * (Splat) Operator Do