Isn't there any way put functions in a list?

I want to use a function like method in an OOP programming.

If there is a list which is named k,
then I want to have a list like

k={1,3,4,a,whatever,f[x_String]:=Print[x<>"Samy"]}
k[[5]]["Hello, "]

The result I expect from the last input above is “Hello, Samy”.
The point is whether it is possible to deal with functions as elements in a list
so that we can get the ability of OOP’s method features.

Thanks. :slight_smile:

Hello,
There are several ways to do this. Here is one:

myPrint[x_] := "x = " <> ToString[x]
fs = {Sin, Cos, myPrint}
fs[[3]][Pi]
Through[fs[21]]

Thank you for help.
Your answer helped me a lot.

There are many problems with this OOP-related-features in Mathematica.
And one is solved due to your explanation.
Have a Good day.

There are number of ways to emulate OOP in Mathematica, if you search Mathematica stackexchange you’ll find number of topics on this. Here is a small note on one method.