# Error while using Optimization.jl

**URL:** <https://discourse.julialang.org/t/error-while-using-optimization-jl/112002>\
**Category:** General Usage\
**Tags:** question, package, optimization\
**Created:** [March 23, 2024, 3:46am UTC](https://discourse.julialang.org/t/error-while-using-optimization-jl/112002 "2024-03-23T03:46:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [March 23, 2024, 5:39am UTC](https://discourse.julialang.org/t/error-while-using-optimization-jl/112002/2 "2024-03-23T05:39:17Z")

</div>

It’s hard to figure things out at the moment, can you post a complete example and try to format your code a little better?

Off the top of my head I would bet that `ddprob` is a matrix, and that you should be indexing it as `ddprob[i, :]` instead of `ddprob[i][:]` (which would work in Python). In Julia, whatever the shape of the array `a`, `a[i]` for integer `i` is the `i`-th element in the flattened array, hence a scalar. That’s why you cannot apply `getindex(..., :)` (“colon”) on it.

> [@Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757):
>
> Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

_[View the full topic](https://discourse.julialang.org/t/error-while-using-optimization-jl/112002)._
