Convert Erlang code to elixir in mnesia delete function?

61 Views Asked by At

I need to convert this Erlang code to Elixir.

fun(OtpTemp, otp) when OtpTemp#otp.genenrated_time < time  ->  
               [OtpTemp | otp];  
             (_, otp) ->  
                IO.inspect(otp)  
           end,
1

There are 1 best solutions below

2
Aleksei Matiushkin On

This is not a valid code in the first place. Erlang has no clue about IO.inspect/1 and (_, otp) would raise as well.

Record might (or might not) be a map in elixir, funs are funs.

fn 
  %{generated_time: gt} = temp, otp when gt < time  -> [temp | otp]
  _, otp -> IO.inspect(otp)  
end