What is the way of declaring an array in JavaScript?

The preferred way is to always use the literal syntax with square brackets; its behaviour is predictable for any number of items, unlike Array‘s. What’s more, Array is not a keyword, and although it is not a realistic situation, someone could easily overwrite it: However, the larger issue is that of consistency. Someone refactoring code could come across … Read more

VirtualBox won’t run win10: Failed to open a session for the virtual machine w10. Result Code: NS_ERROR_FAILURE (0x80004005)

VirtualBox Version: 6.1.22 r144080 (Qt5.6.3) Host Operating System: MacOS BigSur I came across exactly same issue, where clicking on add to choose image was crashing the dialog. This issue persists in the latest version of Virtual Box for Mac. I could figure out couple of ways to avoid clicking on Add button to choose image. … Read more

Officially, what is typename for?

Following is the quote from Josuttis book: The keyword typename was introduced to specify that the identifier that follows is a type. Consider the following example: Here, typename is used to clarify that SubType is a type of class T. Thus, ptr is a pointer to the type T::SubType. Without typename, SubType would be considered a static member. Thus would be a multiplication of value SubType of type T with ptr.

Converting double to integer in Java

is there a possibility that casting a double created via Math.round() will still result in a truncated down number No, round() will always round your double to the correct value, and then, it will be cast to an long which will truncate any decimal places. But after rounding, there will not be any fractional parts remaining. Here are the docs from Math.round(double): … Read more

Regular expression negative lookahead

A negative lookahead says, at this position, the following regex can not match. Let’s take a simplified example: The last example is a double negation: it allows b followed by c. The nested negative lookahead becomes a positive lookahead: the c should be present. In each example, only the a is matched. The lookahead is only a condition, and does not add to … Read more

Convert Set to List without creating new List

You can use the List.addAll() method. It accepts a Collection as an argument, and your set is a Collection. EDIT: as respond to the edit of the question.It is easy to see that if you want to have a Map with Lists as values, in order to have k different values, you need to create k different lists.Thus: You cannot avoid … Read more

AWS Lambda:The provided execution role does not have permissions to call DescribeNetworkInterfaces on EC2

This error is common if you try to deploy a Lambda in a VPC without giving it the required network interface related permissions ec2:DescribeNetworkInterfaces, ec2:CreateNetworkInterface, and ec2:DeleteNetworkInterface (see AWS Forum). For example, this a policy that allows to deploy a Lambda into a VPC: