Terraform failing with Invalid for_each argument / The given “for_each” argument value is unsuitable

Explanation This error is often caused by passing a list to for_each, but for_each only works with unordered data-types, i.e. with sets and maps. Solution The resolution depends on the situation. List of strings If the list is just a list of strings, the easiest fix is to add a toset()-call to transform the list … Read more

Is it safe to use a C++11 range-based for-loop with an rvalue range-init? [duplicate]

Yes, it’s perfectly safe. From [class.temporary]/4-5: There are two contexts in which temporaries are destroyed at a different point than the end of the fullexpression. The first context is when a default constructor is called […] The second context is when a reference is bound to a temporary. The temporary to which the reference is … Read more

How do I use a foreach loop in Java to loop through the values in a HashMap?

A slightly more efficient way to do this: Map<MyClass.Key, String> data = (HashMap<MyClass.Key, String>) getData(); StringBuffer sb = new StringBuffer(); for (Map.Entry<MyClass.Key,String> entry : data.entrySet()) { sb.append(entry.getKey()); sb.append(“: “); sb.append(entry.getValue()); } return sb.toString(); If at all possible, define “getData” so you don’t need the cast.

Reverse order of For Each loop

It’s not possible to loop backwards using the for each loop syntax. As an alternative you can use a For i = a To 1 Step -1 loop: Sub reverseForEach() Dim i As Long, rng As Range Set rng = ActiveSheet.Range(“A1:B2”) For i = rng.Cells.Count To 1 Step -1 Debug.Print rng.item(i).Address ‘ Or shorthand rng(i) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)