Grails def vs Object vs Void

what is the difference between these 3?

def search(String id) { //code } Object search(String id) { //code } void search(String id) { //code } 

specifically between def and Object .

+6
source share
1 answer

def is an alias for Object , so the first 2 signatures are identical.

the difference between 1st and 3rd is that you can return null or an instance of any class from 1 and 2, while you can only return null from 3rd.

+10
source

Source: https://habr.com/ru/post/979975/


All Articles