What's "context ?: return binding.root" meaning in Android Fragment?

Viewed 92

I am checking Sunflower sample app from Google. And I found an interesting part.

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?,
    ): View {
        binding = FragmentMainBinding.inflate(inflater, container, false)
        context ?: return binding.root
        return binding.root
    }

Here, it uses context ?: return binding.root I don't get it because whether context is null or not, it will return binding.root anyway.

Is there any differences?

0 Answers
Related