Help with function

Help with function

Hello, I was wondering if someone could tell me why my function is not working. Here is my function that I have: 


  1. String Bar_Code(String X)
  2. {
  3. //remove serial
  4. if(X.contains("--"))
  5. {
  6. sku4 = X.getPrefix("--");
  7. }
  8. else
  9. {
  10. sku4 = X;
  11. }
  12. //Find Book 
  13. if(sku4.contains("97816804") == true)
  14. {
  15. Book3 = Books[Barcode == sku4];
  16. }
  17. else if(sku4.contains("9781942") == true)
  18. {
  19. Book3 = Books[Barcode == sku4];
  20. }
  21. else if(sku4.contains("9780934") == true)
  22. {
  23. Book3 = Books[Barcode == sku4];
  24. }
  25. else
  26. {
  27. Book3 = Books[Book == sku4];
  28. }
  29.  return Book3;
  30. }
 
But when I try to call it with this 

  1.  Book3 = thisapp.Bar_Code(input.SKU);

I am getting an error that says invalid collection variable.