Code Monkey home page Code Monkey logo

Comments (9)

lfeng1420 avatar lfeng1420 commented on May 2, 2024

加一个判断property是否为null的方法

from behaviac.

leviyuan avatar leviyuan commented on May 2, 2024

实际工作中策划很容易就搞出这种东西
返错什么的都很好接受,直接崩掉就难过了~

from behaviac.

lfeng1420 avatar lfeng1420 commented on May 2, 2024

那可以在调用property的方法之前判断一下是否为null,为null就输出错误trace然后返回

from behaviac.

lfeng1420 avatar lfeng1420 commented on May 2, 2024

想到的就这两种办法,呃。。。。

from behaviac.

lfeng1420 avatar lfeng1420 commented on May 2, 2024

我还以为是C#😂

from behaviac.

leviyuan avatar leviyuan commented on May 2, 2024

测试了一下,的确可以加判断null来解决
还以为是在behaviac调用时候就挂了

from behaviac.

lfeng1420 avatar lfeng1420 commented on May 2, 2024

能解决就好

from behaviac.

leviyuan avatar leviyuan commented on May 2, 2024

还有另外一种情况,如果不是调用方法,而是访问属性,也是直接挂掉的~ 没法做保护

from behaviac.

lfeng1420 avatar lfeng1420 commented on May 2, 2024

访问属性前不是也可以判断下property是否为nullptr么?

from behaviac.

Related Issues (20)

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.