liuyanjun0826
V2EX  ›  Android

这段代码改变后是什么意思?

  •  
  •   liuyanjun0826 · Dec 4, 2018 · 11999 views
    This topic created in 2723 days ago, the information mentioned may be changed or developed.
    之前
    val src = attributes.getValue("", "src")
    val sWidth = attributes.getValue("", "width")
    val sHeight = attributes.getValue("", "height")
    之后
    val src: String? = attributes.getValue("", "src")
    val sWidth: String? = attributes.getValue("", "width")
    val sHeight: String? = attributes.getValue("", "height")
    3 replies    2018-12-08 09:08:03 +08:00
    siyehua
        1
    siyehua  
       Dec 5, 2018   ❤️ 1
    不能学一下 kotlin ?
    attributes.getValue("", "src") 是用 java 写的,如果它没有用注解指明返回的值是否可空,kotlin 无法判断时候可 null,这是时候会将 src 这个变量当成不空处理。
    改了之后就是指明这个返回结果可能为空
    liuyanjun0826
        2
    liuyanjun0826  
    OP
       Dec 5, 2018
    @siyehua 我在这里看到的,https://gitlab.com/spacecowboy/Feeder/issues/156 ,我在使用这款 Android RSS Reader,因为经常出现读取 Feeder 后卡死,故来询问,由于最近身体不好,加上所处之处不方便翻墙,所以无法正常 Google 之,请教有没有比较好的教程可供分享,谢谢。
    liuyanjun0826
        3
    liuyanjun0826  
    OP
       Dec 8, 2018
    @siyehua kotlin 是不是直接 also 了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3018 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 13:22 · PVG 21:22 · LAX 06:22 · JFK 09:22
    ♥ Do have faith in what you're doing.