Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9724

Elvis operator covert double to null in addiction

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • 2.4.19, 2.5.13
    • None
    • GroovyScriptEngine
    • None

    Description

      Below statement will return error unexpected:

      // code placeholder
      
      def vo = [INIT:0.00, PURCHASED:null]
      println (vo.INIT?:0.00) + (vo.PURCHASED?:0.00)
      

      The error : 

       

      Caught: java.lang.NullPointerException: Cannot execute null+0.00
      java.lang.NullPointerException: Cannot execute null+0.00
      at jdoodle.run(jdoodle.groovy:2)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

       

      Note: Below expressions report errors as well:

       

      // code placeholder
      println (vo.INIT?:0.00 + vo.PURCHASED?:0.00)
      println (vo.INIT?:0.00) + (vo.PURCHASED?:0.00)
      println vo.INIT?:0.00 + vo.PURCHASED?:0.00
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            scottmonk Scott.Wu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: