What does “.()” mean in Kotlin?

A function that takes in nothing and returns nothing in Kotlin looks like: var function : () -> Unit The difference is that the function in your code takes in nothing, returns nothing, but is invoked on an object. For example, class Builder (val multiplier: Int) { fun invokeStuff(action: (Builder.() -> Unit)) { this.action() } … Read more

How does using a function (callback) as an argument to another function work in Python?

Yes, this is possible. myfunc can call the passed-in function like: def myfunc(anotherfunc, extraArgs): anotherfunc(*extraArgs) Here is a fully worked example: >>> def x(a, b): … print(‘a:’, a, ‘b:’, b) … >>> def y(z, t): … z(*t) … >>> y(x, (‘hello’, ‘manuel’)) a: hello b: manuel

Select/map each item of a Powershell array to a new array

An array in Powershell is declared with @() syntax. % is shorthand for foreach-object. Let’s declare an array with all the file names and loop through it with foreach. join-path combines a path and a child path into a single path. $files = @(“file1.txt”, “file2.txt”) $pFiles = $files | % {join-path “c:\temp” $_ } $pFiles … Read more

Difference between using a HOC vs. Component Wrapping

Higher-Order Components (HOC) and Container Components are different. They have different use cases and solve similar, but different problems. HOC are like mixins. They are used to compose functionality that the decorated component is aware of. This is opposed to Container Components that wrap children and allow the children to be dumb (or not aware … Read more

What is `lambda` in Python code? How does it work with `key` arguments to `sorted`, `sum` etc.?

A lambda is an anonymous function: >>> f = lambda: ‘foo’ >>> print f() foo It is often used in functions such as sorted() that take a callable as a parameter (often the key keyword parameter). You could provide an existing function instead of a lambda there too, as long as it is a callable … Read more

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