title: Check if an array contains a value in ksh with "case"
body: <p>I have an array containing possible leap years and I'd like to check if a given year may belong or not to this array.  </p>
  
  <pre><code>#!/bin/ksh
  
  leap_yrs=()
  for i in {1852..2010..4}; do
      leap_yrs+=("$i")
  done
  </code></pre>
  
  <p>I've found here <a href="https://stackoverflow.com/questions/3685970/check-if-an-array-contains-a-value">Check if an array contains a value</a> the following code</p>
  
  <pre><code>year=1900
  case "${leap_yrs[@]}" in *"${year}"*) 
  echo "it could be a leap year"
  ;; 
  esac
  </code></pre>
  
  <p>It works but I do not know why.</p>
  
  <p>I would have written something like</p>
  
  <pre><code>year=1900
  case "$year" in *"${leap_yrs[@]}"*) 
  echo "it could be a leap year"
  ;; 
  esac
  </code></pre>
  
  <p>but this does not work.</p>
  
  <p>Could I have some explanation?
  Thanks</p>
  
  <p>MatteP</p>