100DaysOfGameDev: Day 9

Another day, another chapter. The lambdas in JS and Java seemed much simpler, than in C++. One differentiating feature, that pops up to the eye is the capture list [], which in the minimal lambda syntax []{}; allows the user to access the variables in local scope with precise control. You can specify to either access the variables by reference or by value ( which will supply the copy to not modify the original value ). Another interesting thing about lambdas' is that they don't have a specifically defined type, rather they are called closure type and represent function objects, where you overwrite the void operator() const function. No two lambdas have the same type. The second topic discussed the chapter was casting. Both the C++ way using, staticcast, reinterpretcast, constcast, dynamiccast, the construction of value of type T from v T{v}, and the C way with good old (T)v. Almost always the C++ mechanisms are preferred over the C way when writing a C++ code xD However, it will be even better if the 'bad-behaving` casting is avoided altogether. That's it for today folks, see you tomorrow!