Since your resume mentions Python, write code solution for a given scenario.
Implement longest_distinct_subarray(nums) to return the length of the longest contiguous subarray containing only distinct values. Return 0 when nums is empty.
Input is a list of integers, and output is an integer length.
longest_distinct_subarray(nums)
def longest_distinct_subarray(nums):