Git Product home page Git Product logo

kotlin-unwrap's Issues

unwrap했을때 하나라도 null일 경우에 타는 블럭

inline fun <T1, T2, R> unwrap(
        t1: T1?,
        t2: T2?,
        block: (T1, T2) -> R,
        block2: () -> R): R? {
    return if (t1 != null
            && t2 != null) {
        block(t1, t2)
    } else {
        block2()
    }

이런식으로 탔으면 좋겠다 싶을때가 있었는데, 이렇게 만들지 않고 할 수 있는 방법이 있을까요?

Rename `nah` to an english word

In the syntax unwrap(x) {x -> } nah {} the nah function naming is not ideal.

I suppose NAH is an acronym for "null a.. h.."? Hm, I have no idea. Anyway, it would read better if it were a natural english word, like unwrap.. or ... Additionally, NAH very strongly resembles a Russian expletive for "go f*** yourself" :(

Refactor code to make Func class more readable

I think in Func.kt file you can check variables in more elegant way:

    val hasNull = arrayOf<Any?>(t1, t2).contains(null)
    if (!hasNull) block(t1, t2)
    return Unwrap(valid = !hasNull)

Instead of

    return Unwrap().apply {
        if (t1 != null
                && t2 != null) {
            valid = true
            block(t1, t2)
        }
    }

To do it you should make valid field as constructor parameter. It make your code more readable and maintanable and also allow explicitly specify valid field that is more preferable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.