Questions on Array Reducation in Constraint

I am quite confused about the with clause, this is the question description and answer from other forum post:
Q: Write a constraint so that 10 elements of the array arr have the value of 5.
A:


   class numberGen;
   int i,j;
   rand bit[7:0] arr[100];
   function new();
      i = 5; j =10;
   endfunction
   constraint pick_ij { arr.sum(item) with (int'(item == i)) == j;}
endclass : numberGen

My understanding of this code is: for every item in arr, if it equal to i, then sum up the comparison results and constrain to j, because the comparison results are 1-bit, so we need a int cast.

Then I got another confusion on other post,

Q:Write constraint make a value have a value inside array with index ranging from 3 to count:
A:Answered by Dave


    class pkt;
        rand bit [3:0] array[12];
        rand bit [3:0] value;
        int count;
        function new(int cnt);
            count = cnt;
            this.randomize();
        endfunction: new

        constraint c {
          array.or() with (item.index inside {[3:count]} && item == value);// **hard to understand the condition after &&**
        }
    endclass: pkt

For this with clause, I understand the first part: for every item which index not less than 3, but I have difficulty to understand the second part, does it constrain the every element to value? or it is a if condition check like the first example? what if we swap the variable like value == item?

Looking forward to the detail reply.
Thank you!!

In reply to kuangqq08:

class numberGen;
   int i,j;
  rand bit[7:0] arr[25];
  rand bit num_10[15];
   function new();
      i = 5; j =10;
   endfunction
  constraint c1 {
    foreach(arr[i]) 
      if(arr[i]==10) num_10[i]==1;
    else num_10[i] == 0;
  }
  constraint c2 {
    num_10.sum() with (int'(item)) == 10;
  }
endclass : numberGen

This is working for me.