Code Monkey home page Code Monkey logo

Comments (4)

rametta avatar rametta commented on June 9, 2024

@khtan Do you have any suggestion on how to make it more clear?

from pratica.

khtan avatar khtan commented on June 9, 2024

Hi Rametta, sorry for not responding in time. Hope you can still read my comment and respond.

This is the original code:

isOver6Feet({ height: 4.5 })
  .map(h => h / 2.2)
  .cata({
    Just: h => console.log(h), // this function doesn't run
    Nothing: () => console.log(`person is not over 6 feet`)
  })

Suggestion 1:
Use 2 examples, one with height 4.5, the other with height 7.5 to show the
2 branches of the code, and following the pattern of your original comments

isOver6Feet({ height: 4.5 })
  .cata({
    Just: h => console.log(h), // this function doesn't run
    Nothing: () => console.log(`person is not over 6 feet`)
  })
isOver6Feet({ height: 7.5 })
  .cata({
    Just: h => console.log(h), // prints 7.5
    Nothing: () => console.log(`person is not over 6 feet`) // this function doesn't run
  })

Suggestion 2:
Take out the map(h => h /2.2 ) because it does not add to the understanding how Maybe is used.
In fact it raises more questions like
a. Is 2.2 an arbitrary constant or a conversion factor
b. Since the height is in feet, is 2.2 a conversion from imperial to metric
etc

from pratica.

rametta avatar rametta commented on June 9, 2024

@khtan perhaps you can open a PR with your suggestion? Would be very helpful!

from pratica.

khtan avatar khtan commented on June 9, 2024

from pratica.

Related Issues (12)

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.